Passing Command Line Arguments to a LaTeX Document
| ( ! ) Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/bbbart/www/htdocs/blog/wp-content/plugins/vimcolor/wp-vimcolor.php on line 105 | ||||
|---|---|---|---|---|
| Call Stack | ||||
| # | Time | Memory | Function | Location |
| 1 | 0.0001 | 54108 | {main}( ) | ../index.php:0 |
| 2 | 0.0002 | 57812 | require( '/home/bbbart/www/htdocs/blog/wp-blog-header.php' ) | ../index.php:17 |
| 3 | 0.1556 | 13997152 | require_once( '/home/bbbart/www/htdocs/blog/wp-includes/template-loader.php' ) | ../wp-blog-header.php:16 |
| 4 | 0.1568 | 14062416 | include( '/home/bbbart/www/htdocs/blog/wp-content/themes/svelt/archive.php' ) | ../template-loader.php:52 |
| 5 | 0.1811 | 14170740 | the_content( ) | ../archive.php:35 |
| 6 | 0.1815 | 14172120 | apply_filters( ) | ../post-template.php:167 |
| 7 | 0.1847 | 14181348 | call_user_func_array ( ) | ../plugin.php:166 |
| 8 | 0.1847 | 14181348 | vim_color( ) | ../plugin.php:0 |
| 9 | 0.1847 | 14181348 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 10 | 0.1848 | 14186920 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 11 | 0.1848 | 14186920 | vimcolor_process_color( ) | ../wp-vimcolor.php(143) : regexp code:6 |
| 12 | 0.1939 | 14205124 | fread ( ) | ../wp-vimcolor.php:105 |
| ( ! ) Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/bbbart/www/htdocs/blog/wp-content/plugins/vimcolor/wp-vimcolor.php on line 105 | ||||
|---|---|---|---|---|
| Call Stack | ||||
| # | Time | Memory | Function | Location |
| 1 | 0.0001 | 54108 | {main}( ) | ../index.php:0 |
| 2 | 0.0002 | 57812 | require( '/home/bbbart/www/htdocs/blog/wp-blog-header.php' ) | ../index.php:17 |
| 3 | 0.1556 | 13997152 | require_once( '/home/bbbart/www/htdocs/blog/wp-includes/template-loader.php' ) | ../wp-blog-header.php:16 |
| 4 | 0.1568 | 14062416 | include( '/home/bbbart/www/htdocs/blog/wp-content/themes/svelt/archive.php' ) | ../template-loader.php:52 |
| 5 | 0.1811 | 14170740 | the_content( ) | ../archive.php:35 |
| 6 | 0.1815 | 14172120 | apply_filters( ) | ../post-template.php:167 |
| 7 | 0.1847 | 14181348 | call_user_func_array ( ) | ../plugin.php:166 |
| 8 | 0.1847 | 14181348 | vim_color( ) | ../plugin.php:0 |
| 9 | 0.1847 | 14181348 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 10 | 0.1949 | 14204704 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 11 | 0.1949 | 14204704 | vimcolor_process_color( ) | ../wp-vimcolor.php(143) : regexp code:1 |
| 12 | 0.2002 | 14204872 | fread ( ) | ../wp-vimcolor.php:105 |
| ( ! ) Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/bbbart/www/htdocs/blog/wp-content/plugins/vimcolor/wp-vimcolor.php on line 105 | ||||
|---|---|---|---|---|
| Call Stack | ||||
| # | Time | Memory | Function | Location |
| 1 | 0.0001 | 54108 | {main}( ) | ../index.php:0 |
| 2 | 0.0002 | 57812 | require( '/home/bbbart/www/htdocs/blog/wp-blog-header.php' ) | ../index.php:17 |
| 3 | 0.1556 | 13997152 | require_once( '/home/bbbart/www/htdocs/blog/wp-includes/template-loader.php' ) | ../wp-blog-header.php:16 |
| 4 | 0.1568 | 14062416 | include( '/home/bbbart/www/htdocs/blog/wp-content/themes/svelt/archive.php' ) | ../template-loader.php:52 |
| 5 | 0.1811 | 14170740 | the_content( ) | ../archive.php:35 |
| 6 | 0.1815 | 14172120 | apply_filters( ) | ../post-template.php:167 |
| 7 | 0.1847 | 14181348 | call_user_func_array ( ) | ../plugin.php:166 |
| 8 | 0.1847 | 14181348 | vim_color( ) | ../plugin.php:0 |
| 9 | 0.1847 | 14181348 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 10 | 0.2006 | 14204704 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 11 | 0.2006 | 14204704 | vimcolor_process_color( ) | ../wp-vimcolor.php(143) : regexp code:1 |
| 12 | 0.2060 | 14204872 | fread ( ) | ../wp-vimcolor.php:105 |
| ( ! ) Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/bbbart/www/htdocs/blog/wp-content/plugins/vimcolor/wp-vimcolor.php on line 105 | ||||
|---|---|---|---|---|
| Call Stack | ||||
| # | Time | Memory | Function | Location |
| 1 | 0.0001 | 54108 | {main}( ) | ../index.php:0 |
| 2 | 0.0002 | 57812 | require( '/home/bbbart/www/htdocs/blog/wp-blog-header.php' ) | ../index.php:17 |
| 3 | 0.1556 | 13997152 | require_once( '/home/bbbart/www/htdocs/blog/wp-includes/template-loader.php' ) | ../wp-blog-header.php:16 |
| 4 | 0.1568 | 14062416 | include( '/home/bbbart/www/htdocs/blog/wp-content/themes/svelt/archive.php' ) | ../template-loader.php:52 |
| 5 | 0.1811 | 14170740 | the_content( ) | ../archive.php:35 |
| 6 | 0.1815 | 14172120 | apply_filters( ) | ../post-template.php:167 |
| 7 | 0.1847 | 14181348 | call_user_func_array ( ) | ../plugin.php:166 |
| 8 | 0.1847 | 14181348 | vim_color( ) | ../plugin.php:0 |
| 9 | 0.1847 | 14181348 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 10 | 0.2066 | 14205100 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 11 | 0.2066 | 14205100 | vimcolor_process_color( ) | ../wp-vimcolor.php(143) : regexp code:3 |
| 12 | 0.2121 | 14205268 | fread ( ) | ../wp-vimcolor.php:105 |
| ( ! ) Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/bbbart/www/htdocs/blog/wp-content/plugins/vimcolor/wp-vimcolor.php on line 105 | ||||
|---|---|---|---|---|
| Call Stack | ||||
| # | Time | Memory | Function | Location |
| 1 | 0.0001 | 54108 | {main}( ) | ../index.php:0 |
| 2 | 0.0002 | 57812 | require( '/home/bbbart/www/htdocs/blog/wp-blog-header.php' ) | ../index.php:17 |
| 3 | 0.1556 | 13997152 | require_once( '/home/bbbart/www/htdocs/blog/wp-includes/template-loader.php' ) | ../wp-blog-header.php:16 |
| 4 | 0.1568 | 14062416 | include( '/home/bbbart/www/htdocs/blog/wp-content/themes/svelt/archive.php' ) | ../template-loader.php:52 |
| 5 | 0.1811 | 14170740 | the_content( ) | ../archive.php:35 |
| 6 | 0.1815 | 14172120 | apply_filters( ) | ../post-template.php:167 |
| 7 | 0.1847 | 14181348 | call_user_func_array ( ) | ../plugin.php:166 |
| 8 | 0.1847 | 14181348 | vim_color( ) | ../plugin.php:0 |
| 9 | 0.1847 | 14181348 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 10 | 0.2125 | 14204836 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 11 | 0.2125 | 14204836 | vimcolor_process_color( ) | ../wp-vimcolor.php(143) : regexp code:1 |
| 12 | 0.2177 | 14205004 | fread ( ) | ../wp-vimcolor.php:105 |
Some time ago, someone asked me if I knew a way to pass command line arguments to LaTeX documents. My first response was that this ought to be impossible; being a compiler, LaTeX cannot in any way alter it’s input files. But command line parameters can alter the output without touching the input of course.
This has kept me thinking for a while, and at the end I came up with some kind of a solution.
Let’s take a simple LaTeX file:
.
We will define the output of as a command line parameter at LaTeX invocation, as follows:
Result: containing the text “hello world”. Admitted, it’s not the easiest solution, but it does make LaTeX useful inside simple batch jobs!
For more advanced LaTeX templating, I advise using Perl and Text::Template.
Posted in Open Source Adventures, scripting No Comments »