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 | 53388 | {main}( ) | ../index.php:0 |
| 2 | 0.0002 | 56828 | require( '/home/bbbart/www/htdocs/blog/wp-blog-header.php' ) | ../index.php:17 |
| 3 | 0.1461 | 13961420 | require_once( '/home/bbbart/www/htdocs/blog/wp-includes/template-loader.php' ) | ../wp-blog-header.php:16 |
| 4 | 0.1472 | 14031272 | include( '/home/bbbart/www/htdocs/blog/wp-content/themes/svelt/archive.php' ) | ../template-loader.php:52 |
| 5 | 0.1715 | 14115948 | the_content( ) | ../archive.php:35 |
| 6 | 0.1718 | 14117860 | apply_filters( ) | ../post-template.php:167 |
| 7 | 0.1752 | 14122412 | call_user_func_array ( ) | ../plugin.php:166 |
| 8 | 0.1752 | 14122596 | vim_color( ) | ../plugin.php:0 |
| 9 | 0.1752 | 14122932 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 10 | 0.1752 | 14129152 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 11 | 0.1752 | 14129356 | vimcolor_process_color( ) | ../wp-vimcolor.php(143) : regexp code:6 |
| 12 | 0.1854 | 14145636 | 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 | 53388 | {main}( ) | ../index.php:0 |
| 2 | 0.0002 | 56828 | require( '/home/bbbart/www/htdocs/blog/wp-blog-header.php' ) | ../index.php:17 |
| 3 | 0.1461 | 13961420 | require_once( '/home/bbbart/www/htdocs/blog/wp-includes/template-loader.php' ) | ../wp-blog-header.php:16 |
| 4 | 0.1472 | 14031272 | include( '/home/bbbart/www/htdocs/blog/wp-content/themes/svelt/archive.php' ) | ../template-loader.php:52 |
| 5 | 0.1715 | 14115948 | the_content( ) | ../archive.php:35 |
| 6 | 0.1718 | 14117860 | apply_filters( ) | ../post-template.php:167 |
| 7 | 0.1752 | 14122412 | call_user_func_array ( ) | ../plugin.php:166 |
| 8 | 0.1752 | 14122596 | vim_color( ) | ../plugin.php:0 |
| 9 | 0.1752 | 14122932 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 10 | 0.1863 | 14143600 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 11 | 0.1863 | 14143744 | vimcolor_process_color( ) | ../wp-vimcolor.php(143) : regexp code:1 |
| 12 | 0.1927 | 14145156 | 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 | 53388 | {main}( ) | ../index.php:0 |
| 2 | 0.0002 | 56828 | require( '/home/bbbart/www/htdocs/blog/wp-blog-header.php' ) | ../index.php:17 |
| 3 | 0.1461 | 13961420 | require_once( '/home/bbbart/www/htdocs/blog/wp-includes/template-loader.php' ) | ../wp-blog-header.php:16 |
| 4 | 0.1472 | 14031272 | include( '/home/bbbart/www/htdocs/blog/wp-content/themes/svelt/archive.php' ) | ../template-loader.php:52 |
| 5 | 0.1715 | 14115948 | the_content( ) | ../archive.php:35 |
| 6 | 0.1718 | 14117860 | apply_filters( ) | ../post-template.php:167 |
| 7 | 0.1752 | 14122412 | call_user_func_array ( ) | ../plugin.php:166 |
| 8 | 0.1752 | 14122596 | vim_color( ) | ../plugin.php:0 |
| 9 | 0.1752 | 14122932 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 10 | 0.1931 | 14143608 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 11 | 0.1931 | 14143756 | vimcolor_process_color( ) | ../wp-vimcolor.php(143) : regexp code:1 |
| 12 | 0.1983 | 14145172 | 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 | 53388 | {main}( ) | ../index.php:0 |
| 2 | 0.0002 | 56828 | require( '/home/bbbart/www/htdocs/blog/wp-blog-header.php' ) | ../index.php:17 |
| 3 | 0.1461 | 13961420 | require_once( '/home/bbbart/www/htdocs/blog/wp-includes/template-loader.php' ) | ../wp-blog-header.php:16 |
| 4 | 0.1472 | 14031272 | include( '/home/bbbart/www/htdocs/blog/wp-content/themes/svelt/archive.php' ) | ../template-loader.php:52 |
| 5 | 0.1715 | 14115948 | the_content( ) | ../archive.php:35 |
| 6 | 0.1718 | 14117860 | apply_filters( ) | ../post-template.php:167 |
| 7 | 0.1752 | 14122412 | call_user_func_array ( ) | ../plugin.php:166 |
| 8 | 0.1752 | 14122596 | vim_color( ) | ../plugin.php:0 |
| 9 | 0.1752 | 14122932 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 10 | 0.1989 | 14143940 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 11 | 0.1989 | 14144156 | vimcolor_process_color( ) | ../wp-vimcolor.php(143) : regexp code:3 |
| 12 | 0.2052 | 14145972 | 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 | 53388 | {main}( ) | ../index.php:0 |
| 2 | 0.0002 | 56828 | require( '/home/bbbart/www/htdocs/blog/wp-blog-header.php' ) | ../index.php:17 |
| 3 | 0.1461 | 13961420 | require_once( '/home/bbbart/www/htdocs/blog/wp-includes/template-loader.php' ) | ../wp-blog-header.php:16 |
| 4 | 0.1472 | 14031272 | include( '/home/bbbart/www/htdocs/blog/wp-content/themes/svelt/archive.php' ) | ../template-loader.php:52 |
| 5 | 0.1715 | 14115948 | the_content( ) | ../archive.php:35 |
| 6 | 0.1718 | 14117860 | apply_filters( ) | ../post-template.php:167 |
| 7 | 0.1752 | 14122412 | call_user_func_array ( ) | ../plugin.php:166 |
| 8 | 0.1752 | 14122596 | vim_color( ) | ../plugin.php:0 |
| 9 | 0.1752 | 14122932 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 10 | 0.2055 | 14143888 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 11 | 0.2055 | 14144032 | vimcolor_process_color( ) | ../wp-vimcolor.php(143) : regexp code:1 |
| 12 | 0.2108 | 14145444 | 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 »