LaTeX Tricks


Bag of useful tricks of $\LaTeX$, you can preview all the examples in this post at

Useful tricks

new or renew commands

Define new commands or renew existing commands. First, we define our \mypar command in the preamble:

The \mypar command
  1. adds vertical space on the top.
  2. removes the indent at the beginning of the paragraph.
  3. makes the text bold.

Then we can use the new command in our document.

The performance under the open-set protocol is evaluated in terms of [email protected] TAR and FAR are `true accept rate' and `false accept rate'.

Specifically, given several test images, we randomly sample several positive pairs where the two samples share the same identity, and negative pairs...

\mypar{Data Synthesizing.}
By default, the synthetic dataset contains 4,000 identities, and each identity has 100 samples...

The dimension of the synthetic image is $224\times 224$. The stroke width $w$ for principal lines and wrinkles are randomly selected from $1.5\sim 3$ and $0.5\sim 1.5$...

\mypar{Model Training.}
For our proposed method, we first pretrain models on synthesized data for 20 epochs and then finetune on real palmprint datasets.

The maximal learning rate for pretraining is 0.1 and 0.01 for finetune. All models are trained with mini-batch SGD algorithm.

switch with \ifdefined statement

Some times we need multiple versions of the same manuscript. For example, when we submit a paper to a conference/journal, at the meantime we want to put it on arXiv. Due to the page limit of many conferences/journals, we may put more details in the arXiv version. In this case, we are not necessarily to prepare two separate latex documents, we can use the \ifdefined statement to turn on/off some of the content. Below is an example of using \ifdefined to turn on the appendix if the manuscript is prepared for arXiv.

\newcommand{\arXiv}{} % define the arXiv command here
    Some detailed content in the appendix ...
    % nothing here

With above codes, we can conveniently turn on/off the appendix by adding or removing the \newcommand{\arXiv}{} command. We can also switch between normal and anonymous submisions:

    \author{Albert Einstein}
    \author{Anonymous authors}

Useful packages

xcolor: define customized colors

xcolor defines customized colors using ether rgb values:

\definecolor{americanrose}{rgb}{1.0, 0.01, 0.24}
\definecolor{myred}{rgb}{0.753, 0.314, 0.275}
\definecolor{myblue}{rgb}{0.0, 0.24, 0.95}
or hex codes:

overpic: put text on figures

overpic enables you to put text on figures at arbitary positions. You can put regular text, equations, references and whatever element you want on figures at any position at will. Just replace \includegraphics with \begin{overpic}...\end{overpic} and then put text in between.

Here is an example use case of overpic.

        \put(5, 5){a}
        \put(5, 15){reference to~\cite{lamport94}}
        \put(5, 25){\cref{sec:tricks}}
        \put(5, 35){{\color{blue1}{colored text}}}
        \put(5, 45){{\color{yellow1}{colored text}}}
        \put(5, 55){$f(x) = \int x^2dx$}
    \caption{Example image A}
The \put(x, y){xx} command is used to place text on figure, x, y are the coordinates of the text to be placed and xxx is the content to be placed. The outcome is as below:

hyperref: references and links

% define colors
\definecolor{americanrose}{rgb}{1.0, 0.01, 0.24}
\definecolor{myred}{rgb}{0.753, 0.314, 0.275}
\definecolor{myblue}{rgb}{0.0, 0.24, 0.95}
% set colors for lins and references

adjust the colors and behaviours for links and references.

cleveref: automatically cite figures/tables/sections

First, import cleveref in the preamble. Note that we should place\usepackage[capitalize]{cleveref} after \usepackage{hyperref}.


% refer to tables/figures/sections with a unified command
As illustrated in~\cref{xxx}. % a reference to a figure
The numbers in~\cref{xxx}. % a reference to a table
Then, simply use \cref{xxx} for figures/tables/sections and the packages will automatically adds Fig./Tab./Sec. prefixes according to the content.

orcidlink: insert orcid icon with hyperlink

Many templates require the authors' orcid information. For example, the ECCV $\LaTeX$ template requires the orcid of all authors and provides the \orcidlink command to insert the orcid digital ID. But the digital ID is too long and doesn't look as nice as the orcid icon. Below is the author area with digital orcid:

The orcidlink package provides a simple command \orcidlink to insert orcid icons with hyperlink to the orcid webpage. If you are using the ECCV template, only two line of codes can replace the original digital ID with clickable icon:
Below is the results of replacing digital IDs with orcid icons (click to visit the full pdf):

感谢阅读🤗 本文内容谢绝任何形式的转载,如果您想和朋友分享本文内容,请分享本文链接。 如果您发现文中的错误,或者有任何疑问,欢迎在下方留言交流 (留言功能基于 disqus,在中国大陆的读者可能需要一些技术手段才能连接🥲)。