你能帮我用 LaTeX 画出这个 T 表吗?
我正在使用这个代码:
\begin{tabular}{ l| l}
\hline
\textbf{CLorem Ipsum is simply dummy text of the printing and typesetting industry.} & Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum. \\
\textbf{Lorem Ipsum has been the industry's standard dummy text ever since.} & Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero. \\
\textbf{Lorem Ipsum has been the industry's standard.} & The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum \\
\end{tabular}
我得到这个结果:
困难:
- 表格超出页面
- 改变线条粗细
- 更改行高
- 改变列宽
谢谢你!
答案1
以下应该更接近预期的输出:
为了克服上述问题,我对原始代码做了以下更改:
- 对第一列使用了固定宽度的列类型。由于
p
类型 column 是表格左列的明显选择,它会将其内容设置为两端对齐,而您显然想要不规则的右对齐,因此我定义了新的列类型。为了避免在第一列的所有条目中L
重复使用,我添加了。当然,可以根据您的需要调整列的宽度。\textbf
>{\bfseries}
- 用来
tabularx
代替tabular
以确保表格不超过给定的总宽度。其X
类型列自动与尚未被其他表格列占用的剩余空间一样宽。由于类型X
列也调整其内容,因此我将Z
类型列定义为不规则右对齐。 - 为了更改水平线和垂直线的宽度,我添加了
\setlength{\arrayrulewidth}{2pt}
。如果您将此命令添加到序言中,它将影响文档中的所有表格。如果您在文档中的某个地方使用它,它会影响所有后续表格。如果您只想更改一个表格的行,请将其和命令括在一组 `{} 中,就像我在 MWE 中所做的那样。当然,您可以调整宽度参数以满足您的需要。 - 为了增加行高,我添加了
\renewcommand{\arraystretch}{1.5}
。您也可以根据自己的喜好调整因子。
\documentclass{article}
\usepackage{tabularx}
\newcolumntype{Z}{>{\raggedright\arraybackslash}X}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\begin{document}
{
\setlength{\arrayrulewidth}{2pt}
\renewcommand{\arraystretch}{1.5}
\noindent
\begin{tabularx}{\linewidth}{ >{\bfseries}L{5.25cm} | Z}
\hline
CLorem Ipsum is simply dummy text of the printing and typesetting industry. & Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum. \\
Lorem Ipsum has been the industry's standard dummy text ever since. & Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero. \\
Lorem Ipsum has been the industry's standard. & The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum \\
\end{tabularx}
}
\end{document}