如何使用latex生成表格

如何使用latex生成表格,第1张

先使用word或手工将表格草稿画出。

再开始使用latex语法将自己所需要的效果画出来。

首先,引入宏包\usepackage{multirow}

学习表格的相关语法,例如,

multirow 宏包提供了 \multirow 命令可以在表格中排版横跨两行以上的文本。命令的格式如下:

\multirow{nrows}[bigstructs]{width}[fixup]{text}

nrows 设定所占用的行数。

bigstructs 此为可选项,主要是在你使用了 bigstruct 宏包时使用。

width 设定该栏文本的宽度。如果想让 LaTeX 自行决定文本的宽度,则用 * 即可。

fixup 此为可选项,主要用来调整文本的垂直位置。

text 所要排版的文本。可用 \\ 来强迫换行

根据latex的语法,得出第一幅表格的代码为:

%\% Please add the following required packages to your document preamble:

% \usepackage{multirow}

\documentclass{article}

\usepackage{multirow}

\begin{tabular}{|l|l|l|l|}

\hline

\multirow{4}{*}{This is a demo table}

&C2a &

\multirow{4}{*}{This is another one} &C4a\\

&C2b & &C4b\\

&C2c & &C4c\\

&C2d &&C4d\\

\hline

\end{tabular}

\end{document}

第二个表格的latex代码为:

\hline

\multirow{2}{*}{Multi-Row} &

\multicolumn{2}{c|}{Multi-Column} &

\multicolumn{2}{c|}{\multirow{2}{*}{Multi-Row and Col}} \\

\cline{2-3}

&column-1 &column-2 &\multicolumn{2}{c|}{} \\

\hline

label-1 &label-2 &label-3 &label-4 &label-5 \\

\hline

\end{tabular}

望采纳,O(∩_∩)O谢谢,不懂得地方可以再问,一起讨论讨论

在latex中,对于双栏格式的排版,插入一栏图片时,使用的是\begin{figure}……\end{figure} ,插入双栏图片时需在figure的上标中加入符号“*”,如\begin{figure*}……\end{figure*}。

1.在latex插入一张图片(占一栏)比较简单,插入一张图片的代码如下:

\begin{figure}{h}

\centering %使插入的图片居中显示

\includegraphics[height=5cm ,width=8cm,angle=0,scale=]{fig.eps}

\caption{Example twig query and documents } %插入图片的标题,一般放在图片的下方,放在表格的上方

\end{figure}

关键性的语句是:\includegraphics[选项]{图片.eps}

选项:height %指定图片的高度

width %指定图片的宽度

angle %指定图片旋转的角度

还有一个指标叫scale,之缩放图形。

2.在latex插入多张图片(占双栏)就不是那么简单了,笔者知道有两种方法:

法一:使用\begin{minipage}[pos]{width} text \end{minipage}

\begin{figure*}

\centering

\begin{minipage}[!htbp]{0.3\linewidth}

\includegraphics[width=1.5in,angle=-90]{52.eps}

%\caption{fig1}

\label{fig:side:a}

\end{minipage}%

\begin{minipage}[!htbp]{0.3\linewidth}

\includegraphics[width=1.5in,angle=-90]{51.eps}

%\caption{fig2}

\label{fig:side:b}

\end{minipage}

\begin{minipage}[!htbp]{0.3\linewidth}

\includegraphics[width=1.5in,angle=-90]{53.eps}

%\caption{fig3}

\label{fig:side:c}

\end{minipage}

\caption{3 figure}

\end{figure*}

注:笔者不太喜欢这种方法,原因是这种插入方式如果在每个图中使用\caption{fig3

name}给图片做注释的时候不是把三个图片当做一个figure,而是每个图片即每个minipage各使用一个fig标记,三个mingpage相当

于三个图片了,当然也可以不单独对每个图片写个\caption,而是在\caption{3

figure}中对每个figure进行解释说明,所以笔者推崇第二种方法。当然,笔者也许不知道如何设置,有望业内人士指教。

法二:使用subfigure命令,但必须在导演区加入\usepackage{subfigure},否则无法编译过去。

\begin{figure*}[!t]

\centering

\subfigure[Number of elements read] {\includegraphics[height=2in,width=2in,angle=-90]{52.eps}}

\subfigure[Size of disk files scanned] {\includegraphics[height=2in,width=2in,angle=-90]{51.eps}}

\subfigure[Execution time] {\includegraphics[height=2in,width=2in,angle=-90]{53.eps}}

\caption{ PathStack versus TJFast using XMark data }

\label{fig5}

\end{figure*}

这种方法很好,即插入三个子图,可以将三个图片合成一个大图,而且每个图片还可以添加caption,即于subfigure[*]中*内进行解释说明。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11227576.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-14
下一篇2023-05-14

发表评论

登录后才能评论

评论列表(0条)

    保存