[Tex/LaTex] LaTeX in Industry

latex-misc

I know LaTeX is used a lot in academia to format papers and dissertations.
How is LaTeX used in industry and what are some examples? I am wondering
whether knowing LyX will give me a leverage when applying to jobs.

Best Answer

A very common use of LaTeX is for automatic generation of high quality PDF reports that present the results of some routine analysis. For example, given some hydrology data in CSV format:

Date,Flow
2011-12-20,112
2011-12-21,109
2011-12-22,108
2011-12-23,106
2011-12-24,103
2011-12-25,105
2011-12-26,105
2011-12-27,102
2011-12-28,107
2011-12-29,202
2011-12-30,2080
2011-12-31,1940

(from: http://waterdata.usgs.gov)

One could write a quick script:

#!/usr/bin/env python
import sys, os, csv, jinja2

data = [line for line in csv.DictReader(open(sys.argv[1], 'rb'))]

# Change the default delimiters used by Jinja such that it won't pick up
# brackets attached to LaTeX macros.
report_renderer = jinja2.Environment(
  block_start_string = '%{',
  block_end_string = '%}',
  variable_start_string = '%{{',
  variable_end_string = '%}}',
  loader = jinja2.FileSystemLoader(os.path.abspath('.'))
)

template = report_renderer.get_template('report_template.tex')

output = file(sys.argv[2], 'w')
output.write(template.render(data = data))
output.close()

To process a report template that uses some sort of templating language (Jinja in this case):

\documentclass{article}

\usepackage{booktabs}
\usepackage{siunitx}
\DeclareSIUnit\foot{ft}

\begin{document}

\begin{table}
  \centering
  \caption{Average daily flows for the Mad River}

  \begin{tabular}{lS}
    \toprule
    Date & \multicolumn{1}{c}{Flow \si{\foot\cubed\per\second}} \tabularnewline
    \midrule
    %{ for row in data -%}
      %{{ row.Date %}} & %{{ row.Flow %}} \tabularnewline
    %{ endfor %}
    \bottomrule
  \end{tabular}
\end{table}

\end{document}

Bam. A table that had to be tediously compiled by hand each week using Word or Excel is now automatically generated by a re-usable tool:

Example of an automatically generated table

Slap the script into a crontab and forget about it.

Here is a more complicated example produced using Sweave, which is a part of the R programming language:

Example watershed report