默认行高效果
自定义行高效果:看起来更美观、大方些
实现方式:在LaTeX表格中的begin{table}和begin{tabular}之间插入命令renewcommandarraystretch{1.5},其中1.5这个数值是可以自定义的,数值越大,表格越高。
上述自定义行高效果的LaTeX代码如下
documentclass{article}
begin{document}
begin{table}
centering
caption{A Table Demo}
label{tab_demo}
renewcommandarraystretch{1.5}
begin{tabular}{ccccccc}
hline
Animal & Weight & Color & Weight & Color & Weight & Color
hline
Dog & 20.1 & White & 18.0 & Gray & 30.5 & Black
Cat & 10.2 & Yellow & 11.2 & Black & 11.5 & White
Fox & 15.5 & Gold & 15.6 & Gold & 16.5 & Gold
Duck & 2.4 & White & 3.0 & White & 4.0 & White
hline
end{tabular}
end{table}
end{document}
二、自定义列宽默认列宽效果
自定义列宽效果:变得更宽了
实现方式(需要导入graphicx包:usepackage{graphicx}):在LaTeX表格中的begin{table}和begin{tabular}之间插入命令tabcolsep=0.35cm,其中0.35cm是一个自定义宽度。数值越大,表格越长。
上述自定义列宽效果的LaTeX代码如下
documentclass{article}
usepackage{graphicx}
begin{document}
begin{table}
centering
caption{A Table Demo}
label{tab_demo}
tabcolsep=0.35cm
begin{tabular}{ccccccc}
hline
Animal & Weight & Color & Weight & Color & Weight & Color
hline
Dog & 20.1 & White & 18.0 & Gray & 30.5 & Black
Cat & 10.2 & Yellow & 11.2 & Black & 11.5 & White
Fox & 15.5 & Gold & 15.6 & Gold & 16.5 & Gold
Duck & 2.4 & White & 3.0 & White & 4.0 & White
hline
end{tabular}
end{table}
end{document}
三、大表格自适应页面宽度大表格默认效果:太大了,不居中,给人一种越界的感觉,很难看
大表格自适应页面宽度效果:居中显示,表格宽度=页面宽度,看起来更美观、顺眼
实现方式(需要导入graphicx包:usepackage{graphicx}):使用resizebox{1.0linewidth}{!}命令包围tabular的内容,其中,1.0表示将表格的宽度设置为页面宽度(linewidth);如果是0.8的话,那么表格的宽度将被设置为页面宽度的80%;类似的,数值越小,表格宽度越小;当然,也可以设置比1.0还大的数字,但那样的话就不够美观了,因为给人还会是一种表格越界的感觉。
上面实现大表格自适应页面宽度效果的LaTeX代码如下
documentclass{article}
usepackage{graphicx}
begin{document}
begin{table}
centering
caption{A Table Demo}
label{tab_demo}
resizebox{1.0linewidth}{!}{
begin{tabular}{ccccccccccc}
hline
Animal & Weight & Color & Weight & Color & Weight & Color & Weight & Color & Weight & Color
hline
Dog & 20.1 & White & 18.0 & Gray & 30.5 & Black & 30.5 & Black& 30.5 & Black
Cat & 10.2 & Yellow & 11.2 & Black & 11.5 & White & 11.5 & White& 11.5 & White
Fox & 15.5 & Gold & 15.6 & Gold & 16.5 & Gold & 16.5 & Gold & 16.5 & Gold
Duck & 2.4 & White & 3.0 & White & 4.0 & White & 4.0 & White& 4.0 & White
hline
end{tabular}
}
end{table}
end{document}