## LaTeX Shell Escape

by on Mar.13, 2011, under How To ..., LaTeX

One of the lesser known features of LaTeX is its “shell-escape” mode. This is achieved using the LaTeX command \write18{cmdlist} in the document. This facility can be used to incorporate dynamic content or simply run additional processes during the compilation phase. An example document may look something like:

\documentclass{article}
\begin{document}
\immediate\write18{date > tmpdate.tex}
\input{tmpdate}
\immediate\write18{rm tmpdate.tex}
\end{document}


As \write18 is usually disabled on most systems for obvious security reasons, it must be enabled explicitly:

$latex -shell-escape input_file More details are available in the MiKTeX documentation under the heading “Running Programs From Within TeX“. 1 Comment more... ## Graphics format conversion by on Dec.09, 2009, under LaTeX, Linux, Software Up until now I have been using the ‘convert‘ tool that comes with ImageMagick to switch between image formats — mainly for creating EPS files from JPG/PNG (raster format) files for use with LaTeX. Then I came across sam2p. It is a light-weight utility that does one thing only and it does it well: convert between image formats. I’ve been using it for a while now and find that it can greatly reduce files sizes with minimal drop in quality. I’ve even used it to process existing EPS files just to get the reduction in file size. Best of all, it is multi-platform — executables are available for both Windows and Linux on the project homepage. Goodbye convert and hello sam2p! 2 Comments more... ## Squeezing space in LaTeX by on Oct.29, 2009, under How To ..., LaTeX Academic papers and articled often come with a predefined maximum page count and it is common to find that it’s a limit that is easily exceeded. Under such circumstances, it becomes necessary to pull a few “dirty tricks” that squeeze out every last bit of available space. The most common approach is to simply redefine the ‘\baselinestretch’ variable in the preamble of the document. The parameter controls the scaling of the space between the bottom of two successive lines of text. Therefore, the definition used to squeeze that space by 2% is: \renewcommand{\baselinestretch}{0.98}  While that trick alone is sufficient in most cases, it is useful to be aware of other spacing parameters that can be adjusted. The Cambridge University Engineering Department has a nice page with lots of details. I personally find ‘\textfloatsep’ to be one of the more useful ones: \addtolength{\textfloatsep}{-5mm}  It is used to reduce the amount of space that is usually left between a float and the adjacent text block (e.g. end of caption of a top-figure and the text below). 1 Comment more... ## Embedding fonts in a PDF document by on Oct.03, 2008, under How To ..., LaTeX, Linux, Software It is often a good idea (or a requirement) to embed the used font faces in a PDF document. This is easily accomplished using ps2pdf during the final stage of conversion of a document from PS to PDF: $ ps2pdf -sPAPERSIZE=a4 -dPDFSETTINGS=/printer -dCompatibilityLevel=1.3 \
-dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true \
'input_file.ps' 'output_file.pdf'


An explanation of the command options can be found in the Ps2pdf.htm file in the Ghostscript documentations (or here).

[Source]

## Embedded multimedia in LateX/Prosper

by on Dec.01, 2007, under How To ..., LaTeX

The movie15 package by Alexander Grahn is useful for this purpose. The movies embedded, however, cannot be viewed with any PDF reader on Linux.

## Logo in a LaTeX document header/footer

by on Oct.22, 2007, under How To ..., LaTeX

Easily accomplished using the ‘fancyhdr‘ package:

\usepackage{fancyhdr}
\includegraphics[height=0.53in]{img-file}
}
\pagestyle{fancy}


All of that goes into the preamble of the document.

## Duplicate identifiers with hyperref in pdflatex

by on Oct.01, 2007, under LaTeX

The following warning is fairly common when hyperref is used with PDFLaTeX:

! pdfTeX warning (ext4): destination with the same identifier (name{page.1}) ha
s been already used, duplicate ignored


The solution is to use the ‘plainpages=false‘ option with hyperref.

However, this appears to be insufficient for the article class with the ‘titlepage‘ option. To remedy the warning the following is additionally needed around the \maketitle in the body of the document:


\renewcommand{\thepage}{\roman{page}}
\maketitle
\renewcommand{\thepage}{\arabic{page}}


By switching the style of page counter before and after the title page, any ambiguity regarding page numbers is resolved (title page is logically page 1 but LaTex re-initiates the counter on the actual page 1 – leading to 2 successive page 1s).

## User installation of additional TeX/LaTeX classes and styles

by on Aug.09, 2007, under How To ..., LaTeX, Linux

When you are the sysadmin, you can simply drop the new class/style files under the system TeX path (e.g. /usr/share/texmf/tex/) and run ‘texhash’ to have them automatically picked up. But what do you do when you are just a regular user?

TeX/LaTeX looks at the TEXINPUTS environment variable to look for additional locations to search for included/referenced files. Therefore, new classes/styles can be easily added as follows:

1. Create a directory for the files:
$mkdir -p$HOME/tex/latex
2. Place the new class files into that folder (each class can be in its own directory and contain subdirectories):
$cp -a fancy-class$HOME/tex/latex/
3. Export the TEXINPUTS variable and also add it to your $HOME/.bash_profile: $ export TEXINPUTS=.:$HOME/tex/latex//:$TEXINPUTS