基于自己经验,在CV论文Ablation Study Quantitative Comparison中常用到一下Latex的一些功能,特整理如下。
Latex插入表格
latex插入表格可通过以下代码实现
\begin{table}[htbp]
\centering
\caption{Ablation Study}
\label{ablation}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
Model Name & Component 1 & Component 2 & Component 3 & Component 4 & Component 5 & Component 6 \\
\hline
blah blah & blah blah & blah blah & blah blah & blah blah & blah blah & blah blah\\
\hline
\end{tabular}
\end{table}
自动缩放表格使表格不超出页面范围
上面示例可以看到,因为表格较长的缘故,表格已经超出了页面范围,甚至出现了显示不全的情况。遇到这种情况,可以通过添加\resizebox来解决。
\begin{table}[htbp]
\centering
\caption{Ablation Study}
\label{ablation}
\resizebox{\textwidth}{!}{\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
Model Name & Component 1 & Component 2 & Component 3 & Component 4 & Component 5 & Component 6 \\
\hline
blah blah & blah blah & blah blah & blah blah & blah blah & blah blah & blah blah\\
\hline
\end{tabular}}
\end{table}
可以看到,表格实现了自动缩放,不再超出页面范围且与段落同款。
表格单元换行的实现
想要实现表格单元格内的换行,可以在在文档开始处,添加以下句:
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
在表格欲实现单元格内换行处,通过以下方式实现换行
\tabincell{c}{component\\1}
完整示例如下所示:
\begin{table}[htbp]
\centering
\caption{Ablation Study}
\label{ablation}
\resizebox{\textwidth}{!}{\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\tabincell{c}{Model\\Name} & Component 1 & Component 2 & Component 3 & Component 4 & Component 5 & Component 6 \\
\hline
blah blah & blah blah & blah blah & blah blah & blah blah & blah blah & blah blah\\
\hline
\end{tabular}}
\end{table}
在单元格中插入打勾和打叉
要插入好看的打勾和打叉,需要使用到一个包bbding。在文档开始处,添加以下句:
\usepackage{bbding}
bbding可查入各种特殊符号,这边仅以打勾和打叉为示例。
\Checkmark
\CheckmarkBold
\XSolid
\XSolidBrush
对应效果入如下:
设置文字颜色
首先,在文档开始处,添加以下句:
\usepackage{color}
使用方法:
{\color{green}\CheckmarkBold}
{\color{red}\XSolidBrush}