GeneralA Routine for producing LaTeX Documents

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
hfalkenberg
Posts: 1
Joined: Tue Sep 25, 2012 2:51 pm

A Routine for producing LaTeX Documents

Post by hfalkenberg »

Dear all,

I was wondering whether it is possible to automatically write LaTeX code using the shell. Let me explain.

I have a statistical program, which creates a couple of hundred graphs using an algorithm. I would now like to put all these graphs together, say each on one A4 page, giving it a title and maybe a short (automated) description. From my statistics program, I can enter the shell and execute commands. I could thus, in my loop, compile a pre-defined latex-file to PDF. What I still need to find out is whether at each iteration of the loop, I could somehow change the file path of the picture that is to be included in the latex file, or set up a new automated latex file altogether.

I would be glad for any suggestions! And please be gentle, I'm not an absolute crack in computer science.


Cheers,
Hanno

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

A Routine for producing LaTeX Documents

Post by kaiserkarl13 »

Here's a shell script I tossed together; without knowing more specifics, I can't help much more than that.

Code: Select all

#! /bin/bash
# Print header
echo > thedoc.tex '
\documentclass[a4paper]{article}
\usepackage{graphicx}
\begin{document}
'
# Write the images (all PNG files in the "images" subdirectory)
for img in images/*.png
do
  echo "\\includegraphics[height=0.8\textheight]{$img}" >> thedoc.tex
  echo '\clearpage' >> thedoc.tex
done
# Write footer
echo '\end{document}' >> thedoc.tex
Sorry that the syntax highlighting is messed up; there isn't an environment for shell scripts.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

A Routine for producing LaTeX Documents

Post by localghost »

kaiserkarl13 wrote:[…] Sorry that the syntax highlighting is messed up; there isn't an environment for shell scripts....
The GeSHi plug-in also supports bash scripts. I edited your post correspondingly. Just use

Code: Select all

 in the BBCode tag for the correct highlighting of bash scripts. Of course LaTeX is the default setting*. Other supported languages are listed on the project page (column on the lower left side).


Thorsten
____________
[size=85]* It even supports BibTeX syntax, though this is not in the official list of supported languages.[/size]
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

A Routine for producing LaTeX Documents

Post by cgnieder »

localghost wrote:The GeSHi plug-in also supports bash scripts. I edited your post correspondingly. Just use »code=bash« in the BBCode tag for the correct highlighting of bash scripts. Of course LaTeX is the default setting*. Other supported languages are listed on the project page (column on the lower left side).[…]
* It even supports BibTeX, though this is not in the official list of supported languages.
Neat! I didn't know that.
site moderator & package author
kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

A Routine for producing LaTeX Documents

Post by kaiserkarl13 »

cgnieder wrote:
localghost wrote:The GeSHi plug-in also supports bash scripts. I edited your post correspondingly. Just use »code=bash« in the BBCode tag for the correct highlighting of bash scripts. Of course LaTeX is the default setting*. Other supported languages are listed on the project page (column on the lower left side).[…]
* It even supports BibTeX, though this is not in the official list of supported languages.
Neat! I didn't know that.
Neither did I! I tried

Code: Select all

 but that didn't work, so I bailed.  Good to know.
Post Reply