Latex 制作斜线表头、合并行列单元格

这篇文章主要给出一些 Latex 制作斜线表头、合并行单元格与合并列单元格的 demo 演示


latex:制作斜线表头

\begin{tabular}{|l|ccc|}
\hline
\diagbox{Time}{Room}{Day} & Mon & Tue & Wed \\
\hline
Morning & used & used & \\
Afternoon & & used & used \\
\hline
\end{tabular}

效果如下:

这里写图片描述

\begin{tabular}{|@{}l|c|c|r@{}|}
\hline
\diagbox[width=5em,trim=l]{Time}{Day} & Mon & Tue & Wed\\
\hline
Morning & used & used & used\\
\hline 
Afternoon & & used & \diagbox[dir=SW,height=2em,trim=r]{A}{B} \\
\hline
\end{tabular} 

效果如下:

这里写图片描述


LaTex 制作表格 合并行\multirow 合并列\multicolumn

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

    nrows   设定所占用的行数。

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

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

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

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

简单示例:

这里写图片描述

\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} 

复杂例子:

这里写图片描述

\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}    \\
& & & & & \\
\hline
\end{longtable}
\end{document}

更多关于latex表格制作:https://en.wikibooks.org/wiki/LaTeX/Tables#Text_wrapping_in_tables

http://www.ctex.org/documents/packages/table/multirow.htm

  • 12
    点赞
  • 66
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值