Notes on LaTeX

Advanced LaTeX commands and packages

Commands and packages to organize large documents

  1. \input{} and \include{}: Both allow including external tex files into the current file. \input doesn’t start from a new page, but \include does; \include allow nested file including while \input doesn’t.

  2. \import{<directory>}{<filename>} and \subimport{}{}: Similar to \input, but allows compiling the external files in their own directory. See document.

  3. The standalone package: Once \usepackage{standalone} or \RequiredPackage{standalone} is used, the included external files can be a complete LaTeX file. Otherwise, the external files should be code fractions in most cases. Note that, when standalone package is used, the included sub-document will use the preamble from the main document instead. See here for more information.

  4. The CatchFilesBetweenTags package: This package allows to include external code fractions enclosed inside of a pair of tag (can be any words) in the format of %<*tag> and %</tag>. The command \ExecuteMetaData[path/to/file]{tag} is commonly used to execute/expand tagged code into the current document. See this example. It might have problems due to conflicts with other packages or settings. For example, see here for LuaTeX compiling and here for endline characters.

Formatting tricks