LaTeX Techniques

I often use \(\LaTeX\) to compose academic documents, for it provides powerful supply for equation display, entity numbering and bibliography. The layout of the output will always be better than usual WYSIWYG editors. However, the grammar of \LaTeX is very complicated, and there are some obscure usages when achieving certain purposes. Here I write down some practical techniques and experiences that I have gained from using $\LaTeX$ for all these years. I hope that it can be helpful.


WikiBooks is the ultimate \(\LaTeX\) knowledge base for beginners. Its URL is as follows.

https://en.wikibooks.org/wiki/LaTeX


Internationalizing LaTeX

LaTeX with Chinese Support

A special $\LaTeX$ distribution, namely XeLaTeX is needed to compose Chinese documents effectively. To enable Chinese support, one needs to install the XeCJK package and load the fonts from the operating system. The code is as follows.

\usepackage{fontspec}
\usepackage{xeCJK}

% select fonts
\setCJKmainfont[ItalicFont={楷体}, BoldFont={黑体}]{宋体}
\setCJKmonofont{Adobe Fangsong Std}

It is necessary to change the English prefix in captions into Chinese as well, which can be done using the following code.

% using the caption package to change the name of figures and tables
\usepackage[figurename=图, tablename=表]{caption}

% use the following command to change the title of bibliography
\printbibliography[title=引用]

% use the following command to change the caption of code listings
\renewcommand{\lstlistingname}{代码片段}

% use the following command to change the name of chapters
\renewcommand{\chaptername}{}

Beamer Techniques

Beamer is a powerful tool when creating academic slides. It is a bit tricky to use, though.

Toggle Numbered Captions and Bibliography Items

\setbeamertemplate{bibliography item}{\insertbiblabel}
\setbeamertemplate{caption}[numbered]

Disable Buttons in PDF Files

\setbeamertemplate{navigation symbols}{}

Allowing Contents to Span Multiple Pages

Using the allowframebreaks option will allow beamer to do so.

\begin{frame}[allowframebreaks]{引用}
    \printbibliography[title=引用]
\end{frame}

Overlay Control

The following article offers detailed description on overlay control of beamer. It is worth noticing that if the allowframebreaks option of a frame is turned on, then overlay control is disabled on that frame.

https://www.texdev.net/2014/01/17/the-beamer-slide-overlay-concept/

Automatically Create a Slide Before Sections

\AtBeginSection[]{
  \begin{frame}
  \vfill
  \centering
  \begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
    \usebeamerfont{title}\insertsectionhead\par%
  \end{beamercolorbox}
  \vfill
  \end{frame}
}