Skip to main content
  1. Posts/

Nifty LaTeX Techniques -- Series 1

··299 words·2 mins·
Table of Contents

Change font size
#

By default, LaTeX provides several command to change the font size to predefined size. Those command include \scriptsize, \large, \Huge etc. However, even the font size provided by the \Huge command may not be large enough.

In this case, we can use the \fontsize command to change the font size to what we want. The signature of \fontsize command is:

\fontsize{<font_size>}{<baseline_skip>}

The first parameter is the font size and the second parameter is baseline skip. The default font used by LaTeX does not support arbitrary font size, and we have to use another font such as Latin Modern. A minimal example is the follows:

\documentclass{article}
% use the Latin Modern font
\usepackage{lmodern}
\begin{document}
% turn off page numbering
\pagenumbering{gobble}

{\flushleft \fontsize{50}{10}\selectfont 50pt}

{\flushleft \fontsize{100}{10}\selectfont 100pt}

{\flushleft \fontsize{150}{10}\selectfont 150pt}

{\flushleft \fontsize{200}{10}\selectfont 200pt}

\end{document}

In the above code, \selectfont is used to make the font change take effect.

References
#

Produce vertical text
#

Sometimes, we want to produce a vertical text line. This can be achieved by using the \rotatebox box command provided by the graphicx package. A small runnable script is provided below:

% !TEX TS-program = xelatex
\documentclass{article}
\usepackage{graphicx}

\begin{document}
% turn off page numbering
\pagenumbering{gobble}

\rotatebox[origin=c]{90}{\fontsize{50}{5}\selectfont \textbf{Test text.}}
\end{document}

Another way to rotate texts is to use the rotating package, which provides a turn environment to rotate texts to certain angles:

% !TEX TS-program = xelatex
\documentclass{article}
\usepackage{lmodern}
\usepackage{rotating}

\begin{document}
% turn off page numbering
\pagenumbering{gobble}

% rotate the text to 90 degrees counterclockwise
\begin{turn}{90}
    \fontsize{50}{5}\selectfont \textbf{Test text.}
\end{turn}

\end{document}

References
#

Related

全面总结如何在 LaTeX 中使用中文 (2020 最新版)
··222 words·2 mins
Nvim-qt Settings on Windows 10
··732 words·4 mins
How to Plot Unicode Characters with Matplotlib
··461 words·3 mins