Latex Tricks


In this page, I will record several useful Latex tricks, which will save tremendous of time.

Multiple Files

Although many textbooks will suggest “\include” construct, I would recommend “\subfile” construct. Unlike “\include”, “\subfile” will NOT introduce additional new page break after each included file. The usage of this package is straightforward:

\usepackage{subfiles}
......
\subfile{file1}
\subfile{file2}
\subfile{file3}

This is what you will do in the “main” source file. In each sub file, you need to include the following code:

\documentclass[source language=".tex"][/source]{subfiles}
......
\begin{document}
......
\end{document}

where “source.tex” is the name of the “main” source file.

Another simpler choice is “\input” construct, which is to contain the content from the file without a “clearpage”.

Embed All Fonts in PDF files

Usually, we need to make sure all fonts are embedded in the final generated PDF file. It is a requirement for some conference proceedings. For instance, ACM has the following suggestions to embed fonts in PDF files:

dvips -t letter -Pdownload35 -o .ps .dvi

This is sometimes not enough. By using “pdffonts” command, you can check whether the generated PDF file includes all fonts. In addition to “dvips”, another way to embed fonts is:

ps2pdf14 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -dPDFSETTINGS=/printer .ps

Convert LaTex to HTML with Math Support

It is not trivial to convert LaTex to HTML. For old fashion tools, you may use Latex2HTML. But, from the documentation, you can tell that it’s really old. A more modern tool is tex4ht.