LaTeX学习(9)表格

标签:
latex表格it |
分类: Other |
http://s15/mw690/002vBAY3gy6DVv5xUXI7e&690
http://s4/mw690/002vBAY3gy6DVv5Ba4r43&690
http://s13/mw690/002vBAY3gy6DVv5E684fc&690
http://s1/mw690/002vBAY3gy6DVv5GJiM20&690
http://s4/mw690/002vBAY3gy6DVv5Ba4r43&690
http://s13/mw690/002vBAY3gy6DVv5E684fc&690
http://s1/mw690/002vBAY3gy6DVv5GJiM20&690
在latex文件最前面用这个包\usepackage{multirow}
multirow 宏包提供了 \multirow 命令可以在表格中排版横跨两行以上的文本。命令的格式如下:
\multirow{nrows}[bigstructs]{width}[fixup]{text}
nrows
设定所占用的行数。
bigstructs
此为可选项,主要是在你使用了 bigstruct 宏包时使用。
width
设定该栏文本的宽度。如果想让 LaTeX 自行决定文本的宽度,则用 * 即可。
fixup
此为可选项,主要用来调整文本的垂直位置。
text
所要排版的文本。可用 \\ 来强迫换行。
更多介绍与实例:http://www.ctex.org/documents/packages/table/multirow.htm
补充例子1: http://blog.sina.com.cn/s/blog_5e16f1770100u40t.html
\renewcommand{\multirowsetup}{\centering}\begin{tabular}{|l|l|l|l|}\hline\multirow{4}{2cm}{This is a demo table}
& C2a &\multirow{4}{2cm}{This is another one} & C4a\\ & C2b & & C4b\\& C2c & & C4c\\& C2d & & C4d\\\hline\end{tabular}
http://www.ctex.org/documents/packages/images/multirow-2.gif
补充例子2:http://jhengjyun.blogspot.fr/2011/01/latexmulticolumnmultirow.html
通常畫表格需要使用到\multicolumn, \multirow, \hline, \cline四種指令
其中要使用\multirow,必須在前頭先行加入\usepackage{multirow}
直接看例子,Latex程式碼 =>
de style="" >\begin{tabular}{|c|c|c|c|c|}
\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}de>
顯示結果 =>
补充个例子3:http://blog.sina.com.cn/s/blog_5e16f1770100h6jl.html
使用宏包multirow,提供了如下命令:参看http://www.ctan.org/tex-archive/macros/latex/contrib/multirow/
效果图:
http://img.ph.126.net/xcUb1_hHNVUR3c44dIjs_w==/6597200608542095192.jpg
演示代码:
\documentclass{article}
\usepackage{longtable}
\usepackage{rotating}
\usepackage{multirow}
\begin{document}
\begin{longtable}{| c | c | c | c | c | c |}
\hline
& \multicolumn{5}{| c |}{ } \\
& \multicolumn{5}{| c |}{\textbf{\large Father's Occupation}} \\
& \multicolumn{5}{| c |}{ } \\
\hline
& & & & & \\
\multicolumn{1}{|c|}{\textbf{}}
& \multicolumn{1}{|c|}{\textbf{}}
& \multicolumn{1}{c|}{\textbf{Group A}}
& \multicolumn{1}{c|}{\textbf{Group B}}
& \multicolumn{1}{c|}{\textbf{Group C}}
& \multicolumn{1}{c|}{\textbf{Group D}} \\
& & & & & \\
\cline{2-6}
& & & & & \\
\multirow{5}{*}{\begin{sideways}{\textbf{\large Mother's Occupation}}\end{sideways}}
& \textbf{Group A} & $8$ & $3$ & $4$ & $1$ \\
& & & & & \\
\cline{2-6}
& & & & & \\
& \textbf{Group B} & $3$ & $3$ & $0$ & $1$ \\
& & & & & \\
\cline{2-6}
& & & & & \\
& \textbf{Group C} & $0$ & $0$ & $1$ & $0$ \\
& & & & & \\
\cline{2-6}
& & & & & \\
& \textbf{Group D} & $2$ & $0$ & $0$ & $1$ \\
& & & & & \\
\hline
& & & & & \\
& \textbf{Total:} & \textbf{26} & \textbf{10} & \textbf{10} & \textbf{4}