注意此文是讲三线图,不是讲表格绘制。一般表格绘制非常推荐去这里直接生成 Tables Generator,就不用自己去写代码了。 如果要学习一些三线表的写法,请往下看。
简单的三线图可以比较轻松地做出来,在中间使用\toprule
,\midrule
,\bottomrule
就可以实现三线图的基本形式。需要用到\usepackage{bookmarks}
宏包
具体如下
\begin{table*}
\centering
\caption{****}
\begin{tabular}{c|c|c|}
\toprule
1 & 1 & 1
\midrule
1 & 1 & 1
\bottomrule
\end{tabular}
\label{tbl:table-example}
\end{table*}
其中c|c|c|
是指三列都按居中排列,除了c还可以写l(靠左),r(靠右)
,竖线是分割这三列,元素之间用&
分隔开,显示的效果如下:
但是如果要实现一些复杂的三线图就需要一些复杂代码了。给出之前有几个基础,多列合并和多行合并。
%多列合并一般这样使用
\multicolumn{cols}{pos}{text}
第一个参数是合并几列,第二个是合并后内容放哪里可以使用c l r,
第三个是放的内容
%多行合并
\multirow{nrows}[bigstructs]{width}[fixup]{text}
nrows 设定所占用的行数。
bigstructs 此为可选项,主要是在你使用了 bigstruct 宏包时使用。
width 设定该栏文本的宽度。
如果想让 LaTeX 自行决定文本的宽度,则用 * 即可。
fixup 此为可选项,主要用来调整文本的垂直位置。
text 所要排版的文本。可用 \\ 来强迫换行。
所以一般这样使用:
\multirow{number of rows}{*}{text}
下面给出几个一个复杂的绘图,很多情况都遇到了,可以在里面仿着去写
- 表格中写列合并和行合并
%\cline{2-6} % 这样使用cline能画一条横线在2-6 排之间
\begin{table*}
\centering
\begin{tabular}{ccccccc} % 控制表格的格式,7列
\toprule
\multirow{2}{*}{\textbf{Model}} &\multirow{2}{*}{\textbf{Skipped}} & \multirow{2}{*}{\textbf{Dilated}} & \multirow{2}{*}{\textbf{Attention}}&\multirow{2}{*}{\textbf{Fine-Tune}} &
\multicolumn{2}{c}{\textbf{Accuracy}}
\\&&&&&5-way 1-shot & 5-way 5-shot \\
\midrule
\textbf{Relation Net }& \checkmark & & & & 0.8449 &0.8325 \\
\textbf{Relation Net} & \checkmark & & & \checkmark & 0.8950&0.8488 \\
\textbf{Relation Net} & \checkmark & \checkmark & & &0.8624&0.8450 \\
\textbf{Relation Net} & \checkmark & \checkmark & & \checkmark & 0.8866&0.8647 \\
\textbf{Relation Net} & \checkmark & & \checkmark & & 0.8532&0.8599 \\
\textbf{Relation Net} & \checkmark & & \checkmark & \checkmark & 0.9268&0.8925 \\
\cline{1-7} %画一条横线
\textbf{Our model} & \checkmark & \checkmark & \checkmark & & 0.8990&0.8537 \\
\textbf{Our model} & \checkmark & \checkmark & \checkmark & \checkmark& \textbf{0.9486}&\textbf{0.9039} \\
\bottomrule
\end{tabular}
\label{tbl:table1}
\caption{Comparison of different obfuscations in terms of their transformation capabilities}
\end{table*}
能实现的效果如下:
可以多思考一下表格合并是怎么写的,仿着就能写出来。\begin{table*} \end{table*}
如果带*
在两栏环境里面就可以跨栏显示,如果不带*
就是单栏显示,如下:
- 合并及单栏显示
\begin{table}\centering
\begin{tabular}{cccc}
\toprule
Model&Fine-Tune&\multicolumn{2}{c}{Accuracy}\\
\midrule
CNN&\checkmark&\multicolumn{2}{c}{0.709}\\
Siamese Net& &\multicolumn{2}{c}{0.5711}\\
\cline{1-4}
& & \small{5-way 1-shot} &\small{5-way 5-shot}\\
\cline{3-4}
Our model& & 0.8990&0.8537\\
Our model&\checkmark&0.9486&0.9039\\
\bottomrule
\end{tabular}
\label{tbl:CLASSIFICATION RESULTS}
\caption{CLASSIFICATION RESULTS (ACCURACY) ON SCREEN DEFECT DATASET}
\end{table}
显示图如下:
3. 三线图中插入图片
使用minipage
就可以实现
\begin{table*}
\centering
\begin{tabular}{cccccccc}
\toprule
class& Black& Blackpoint& Blackscratch& Mura& Scratch& White& Block\\
\midrule
image & \begin{minipage}[c]{0.1\textwidth}
\includegraphics[width=16mm, height=16mm]{figure/black}
\end{minipage}
& \begin{minipage}[c]{0.1\textwidth}
\includegraphics[width=16mm, height=16mm]{figure/blackpoint}
\end{minipage} &
\begin{minipage}[c]{0.1\textwidth}
\includegraphics[width=16mm, height=16mm]{figure/blackscratch}
\end{minipage}
&
\begin{minipage}[c]{0.1\textwidth}
\includegraphics[width=16mm, height=16mm]{figure/block}
\end{minipage}
&
\begin{minipage}[c]{0.1\textwidth}
\includegraphics[width=16mm, height=16mm]{figure/mura}
\end{minipage}
&
\begin{minipage}[c]{0.1\textwidth}
\includegraphics[width=16mm, height=16mm]{figure/scratch}
\end{minipage}
&
\begin{minipage}[c]{0.1\textwidth}
\includegraphics[width=16mm, height=16mm]{figure/white}
\end{minipage}
\\
\bottomrule
\end{tabular}
\label{tbl:DEFECT DATASET}
\caption{ MOBILE PHONE SCREEN DEFECT DATASET}
\end{table*}
显示如下:
4. 三线图中加入公式
\begin{table}\centering
\caption*{\Large{总~结}} %加*取消显示caption前的table x
\begin{tabular}{c|c}
\toprule
$F$ 表象(基矢 $\psi_{k}$ )&$F^{\prime}$ 表象(基矢 $\left.\psi_{a}^{\prime}\right)$\\
\midrule
\multicolumn{2}{c}{态 $\psi$}\\
$a=\left(\begin{array}{c}a_{1} \\ a_{2} \\ \vdots\end{array}\right), a_{k}=\left(\psi_{k}, \psi\right)$ &
$a^{\prime}=\left(\begin{array}{c}a_{1}^{\prime} \\ a_{2}^{\prime} \\ \vdots\end{array}\right), a_{a}^{\prime}=\left(\psi_{a}^{\prime}, \psi\right)$\\
\cline{1-2}
\multicolumn{2}{c}{力学量 $\hat{L}$}\\
$\begin{array}{c}L=\left(L_{k}\right)=\left(\begin{array}{ccc}L_{11} & L_{12} & \cdots \\ L_{21} & L_{22} & \cdots \\ \cdots & \cdots & \cdots\end{array}\right) \\ L_{k j}=\left(\psi_{k}, \hat{L}, \psi_{j}\right) \end{array}$ & $\begin{array}{c}L^{\prime}=\left(L_{\alpha \beta}^{\prime}\right)=\left(\begin{array}{ccc}L_{11}^{\prime} & L_{12}^{\prime} & \cdots \\ L_{21}^{\prime} & L_{22}^{\prime} & \cdots \\ \cdots & \cdots & \cdots\end{array}\right) \\L_{a \beta}^{\prime}=\left(\psi_{a}^{\prime}, \hat{L} \psi_{\beta}^{\prime}\right)
\end{array}$\\
\bottomrule
\end{tabular}
\label{tbl:zongjie}
\end{table}
显示效果如下: