Skip to main content
โšก Calmops

LaTeX Advanced Typesetting: Professional Document Production

Introduction

LaTeX remains the gold standard for professional document typesetting, particularly in academia, science, and engineering. While basic LaTeX documents are straightforward to create, truly professional output requires understanding advanced typesetting techniques.

In 2026, LaTeX continues to evolve with new packages and workflows, particularly for integration with modern tools like VS Code, Git, and continuous document building. This guide covers advanced typesetting techniques that will help you create publication-quality documents.

Advanced Macro Writing

Defining Custom Commands

% Basic custom command
\newcommand{\pkg}[1]{\texttt{#1}}
\newcommand{\file}[1]{\texttt{#1}}

% Command with optional argument
\newcommand{\code}[2][python]{\texttt{#2}}

% Command with multiple arguments
\newcommand{\highlight}[2]{\textbf{#1: #2}}

% Robust command for moving arguments
\DeclareRobustCommand{\macroname}[1]{%
  \textit{#1}%
}

Creating Environments

% Custom theorem environment
\newtheoremstyle{breaking}
  {3pt}% Space above
  {3pt}% Space below
  {\itshape}% Body font
  {}% Indent amount
  {\bfseries}% Head font
  {.}% Punctuation after head
  {.5em}% Space after head
  {}%

\theoremstyle{breaking}
\newtheorem{break theorem}{\theoremname}[section]

Conditional Logic

% Define conditionals
\newif\ifdraft
\drafttrue  % or \draftfalse

% Use conditional
\ifdraft
  \usepackage{draftwatermark}
  \SetWatermarkText{DRAFT}
\fi

% Check for empty arguments
\makeatletter
\newcommand{\ifempty}[3]{%
  \ifx#1\@empty #3\else #2\fi
}
\makeatother

Professional Document Design

Page Layout

\usepackage{geometry}
\geometry{
  paper=a4paper,
  inner=2.5cm,  % Inner margin
  outer=3.5cm,  % Outer margin  
  top=2.5cm,
  bottom=2.5cm,
  headheight=15pt,
  footskip=1.5cm
}

% Custom headers and footers
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{\nouppercase\leftmark}
\fancyhead[LO]{\nouppercase\rightmark}
\fancyfoot[CE]{\today}

Typography Enhancement

% Microtype for better typesetting
\usepackage{microtype}
\DisableLigatures[f]{encoding = *, family = * }

% Custom font setup
\usepackage{fontspec}
\setmainfont{Charis SIL}[
  Extension = .otf,
  UprightFont = *-Regular,
  BoldFont = *-Bold,
  ItalicFont = *-Italic,
  Ligatures = {Common, Rare}
]

% Use sans-serif for headings
\usepackage{titlesec}
\titleformat*{\section}{\sffamily\Large\bfseries}

Custom Lists

\usepackage{enumitem}

% Custom list with custom labels
\newlist{steps}{enumerate}{2}
\setlist[steps]{
  label=Step \arabic*:,
  font=\bfseries,
  nosep,
  leftmargin=*
}

% Custom description style
\setlist[description]{
  style=nextline,
  font=\normalfont\bfseries,
  labelwidth=120pt,
  leftmargin=130pt
}

Graphics and Floats

Advanced Figure Handling

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{figure}[htbp]
  \centering
  \begin{subfigure}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{figure1}
    \caption{First subfigure}
    \label{fig:1a}
  \end{subfigure}
  \hfill
  \begin{subfigure}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{figure2}
    \caption{Second subfigure}
    \label{fig:1b}
  \end{subfigure}
  \caption{Combined figure with subfigures}
  \label{fig:combined}
\end{figure}

Custom Float Boxes

\usepackage{float}
\usepackage{tcolorbox}

% Custom colored box for listings
\newfloat{code}{htbp}{lod}[section]
\floatname{code}{Listing}

% tcolorbox for fancy boxes
\tcbuselibrary{skins,breakable}
\newenvironment{fancybox}[1][]{
  \begin{tcolorbox}[
    colback=blue!5,
    colframe=blue,
    title=#1,
    breakable
  ]
}{
  \end{tcolorbox}
}

TikZ Graphics

\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,calc}

\begin{tikzpicture}[node distance=2cm, every node/.style={draw,rectangle,minimum width=3cm}]

\node (input) {Input Data};
\node [right of=input] (process) {Processing};
\node [right of=process] (output) {Output};

\draw[->] (input) -- (process);
\draw[->] (process) -- (output);

\end{tikzpicture}

Bibliography Management

Custom Bibliography Styles

\usepackage[style=authoryear, sorting=nyt]{biblatex}
\addbibresource{references.bib}

% Custom bibliography driver
\DeclareBibliographyDriver{online}{
  \printtext{[}\printfield{year}\printtext{]}%
  \newunit
  \printfield{title}%
  \newunit
  \printurl{\thefield{url}}%
}

% Bibliography categories
\DeclareBibliographyCategory{primary}
\DeclareBibliographyCategory{secondary}

\addtocategory{primary}{key1,key2}
\addtocategory{secondary}{key3}

Bibliography Formatting

% Compact citation
\DeclareCiteCommand{\citeauthoronly}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\indexnames{labelname}%
   \printtext[bibhyperref]{\printnames{labelname}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

% In-text citation with year
\DeclareCiteCommand{\citeyearpar}
  {\printfield{year}}

Table Design

Professional Tables

\usepackage{booktabs}
\usepackage{array}
\usepackage{longtable}
\usepackage{csvsimple}

% Professional table styling
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash}m{#1}}

\begin{table}[htbp]
  \centering
  \caption{Professional table example}
  \label{tab:professional}
  \begin{tabular}{lRRR}
    \toprule
    \textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} & \textbf{Column 4} \\
    \midrule
    Row 1 & 100 & 200 & 300 \\
    Row 2 & 150 & 250 & 350 \\
    \bottomrule
  \end{tabular}
\end{table}

Long Tables

\usepackage{longtable}

\begin{longtable}{|l|l|p{5cm}|}
  \caption{Long table spanning pages}
  \label{tab:long} \\
  \hline
  \textbf{Header 1} & \textbf{Header 2} & \textbf{Description} \\
  \hline
  \endfirsthead
  \hline
  \textbf{Header 1} & \textbf{Header 2} & \textbf{Description} \\
  \hline
  \endhead
  \hline
  \multicolumn{3}{r}{\textit{Continued on next page}} \\
  \endfoot
  \hline
  \endlastfoot
  
  % Table content
  Item 1 & Value 1 & Description 1 \\
  Item 2 & Value 2 & Description 2 \\
  % ... more rows
\end{longtable}

Automation and Scripts

Build Automation

#!/bin/bash
# LaTeX build script with multiple passes

FILE="document"

# First pass
pdflatex -interaction=nonstopmode $FILE

# Bibliography
bibtex $FILE

# Second pass
pdflatex -interaction=nonstopmode $FILE

# Third pass  
pdflatex -interaction=nonstopmode $FILE

# Clean auxiliary files
rm -f *.aux *.log *.bbl *.blg *.toc *.out

Git Integration

% Version information from git
\usepackage{gitinfo2}

% Or use this for more control
\immediate\write18{git rev-parse --short HEAD > gitinfo.txt}
\newread\gitfile
\openin\gitfile=gitinfo.txt
\read\gitfile to \gitcommit
\closein\gitfile

% Use \gitcommit for version display

International Typesetting

Multi-language Support

\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{german}
\setotherlanguage{french}

% Hyphenation exceptions
\hyphenation{SomeWord Some-Other-Word}

% Custom language environment
\newenvironment{frenchquote}%
  {\begin{quotation}\begin{french}\itshape}%
  {\end{french}\end{quotation}}

RTL Languages

\usepackage{bidi}
\setRTL

% Two-column with RTL
\usepackage{docmute}
\usepackage{eledmac}

Performance Optimization

Compilation Speed

% Draft mode - skip images
\usepackage{ifdraft}
\ifdraft{}{
  \usepackage{graphicx}
}

% Use externalized TikZ
\usetikzlibrary{external}
\tikzexternalize[prefix=figures/]

% Pre-compile preamble
\usepackage{snapshot}

Output Optimization

% Compress PDF
\pdfminorversion=7
\pdfobjcompresslevel=3

% Embed fonts
\usepackage{cmap}
\usepackage[hidelinks]{hyperref}

Conclusion

Advanced LaTeX typesetting opens up possibilities for creating truly professional documents. The techniques covered hereโ€”from custom macros to sophisticated layout controlโ€”enable you to produce publication-quality output that meets the highest standards.

Remember:

  • Start with a solid document class
  • Use packages for advanced features
  • Keep macros organized in a preamble
  • Test output frequently
  • Use version control for documents

Resources

Comments