1. Cusmotimized commands
    1. \eg, \it, …
    2. \Cref and \cref
  2. About Table
    1. Which package to draw table?
    2. X column in the tabularx
    3. Bold \hline
    4. Multiple rows and columns
    5. Repeated columns
    6. Unbreackable text \mbox
    7. Custom alignment on specific cell
    8. Superscript in table

Cusmotimized commands

\eg, \it, …

With below commands, you can quickly draw a nice e. g., with \eg and other commonly used abbreviations.

% copied from cvpr for \eg, \ie, etc.
\usepackage{xspace}  % used below
\def\eg{\emph{e.g}\onedot} \def\Eg{\emph{E.g}\onedot}
\def\ie{\emph{i.e}\onedot} \def\Ie{\emph{I.e}\onedot}
\def\cf{\emph{cf}\onedot} \def\Cf{\emph{Cf}\onedot}
\def\etc{\emph{etc}\onedot} \def\vs{\emph{vs}\onedot}
\def\wrt{w.r.t\onedot} \def\dof{d.o.f\onedot}
\def\iid{i.i.d\onedot} \def\wolog{w.l.o.g\onedot}
\def\etal{\emph{et al}\onedot}

\Cref and \cref

You can use \cref{to_label} to quickly refer a figure, table, or section, without handling the prefix like Fig.~\ref{fig_label}. \Cref is only used when the reference is at the starting of a sentence, in which case the full name will be displayed, i.e., Figure. 5 instead of Fig. 5.

% copied from cvpr for \cref
\usepackage{etoolbox} % for \AtEndPreamble

About Table

Which package to draw table?

Below are some packages you must know:

  • tabular: The basic one [not recommended].
  • array: A extension of tabular. Depended by most of the other table packages.
  • tabularx: Introduce the useful X column. Recommended.
  • booktabs: Professional looking. Specifically designed for tables without vertical lines.
  • tabularray: A new LaTeX3 package using a new writting logic. Well maintained and powerful. Recommended. You may read my post about it.

I highly recommend using the tabularray package due to its modular design, robust maintenance, and extensive support for customization. I have some notes for this package.

X column in the tabularx

One important feature of the tabularx is the column type X, which automatically expands in order to make the table as wide as specified, e.g., \textwidth. Below are the examples:





However, it’s quite tricky to do alignment in X columns:

{>{\raggedright\arraybackslash}X} % align left
{>{\centering\arraybackslash}X}   % align center
{>{\raggedleft\arraybackslash}X}  % align right

Note that the X column and the c l r columns can be used in the same table:

\begin{tabularx}{\textwidth}{l l l l l *{5}{>{\centering\arraybackslash}X}}

Screenshot from 2022-05-22 20-25-57

In the above example, only the width of the rightest five columns, i.e. the X columns, are auto-ajusted.

Altough the X column is good, there is a drawback that all X columns in the same table share the same width. I think that ideal X columns should have width proportional to their text contained. Below is an example:

\begin{tabularx}{\textwidth}{|X| X| X| X| X| X |X| X| X| X| X|}


As we can see that all X column share the same width. A better width arrangement should be that the columns with long texts have larger width. There are two ways to do that referring to this answer:

  • Using \extracolsep{\fill} inside tabular*.
  • The X[-1] column in the tabularray package.

Bold \hline


% inside table

Multiple rows and columns

\multicolumn{number cols}{align}{text} % align: l,c,r
\multirow{number rows}{width}{text}
% Using * as width, the text argument’s natural width is used.

Repeated columns

*{num_repeated}{alignment} % see the above example

Unbreackable text \mbox




\mbox{Input volume $I_{\tau}$} & Loc. &  Cls. & Detection\\ 


Custom alignment on specific cell


Screenshot from 2022-05-22 20-33-43

Superscript in table

Either using Test$^\dag$ and expalining the superscript in the Table title, or using the \TblrNote{$\dag$} in the tabularray package (longtblr) and describing the superscripts in notes note{$\dag$} = {text} under the table.

\renewcommand\TblrOverlap[1]{#1} % change the overlap style, you may comment this line to check the difference.
caption = {Some introduction. $\dag$: the model with focal loss},
note{$\dag$} = {the model with focal loss},
colspec = {c X},
G-TAD$^\dag$ [1] & Foo \\
BMN\TblrNote{$\dag$} [2] & Bar\\