问题描述
我在Latex(Overleaf)中使用表格格式的环境,希望我的文字自动换行并且合理。我能找到的最接近的是使用\\
语法。这很费力;此外,我希望文本像我文档的其余部分一样合理。我使用的是我发现的here片段,但其中没有自动换行和对齐的文本。我的最低工作示例如下:
\documentclass[11pt,fleqn]{book}
\usepackage{import}
\usepackage{fancyhdr}
\fancyhf{}
\cfoot{\thepage}
\pagestyle{fancy}
\usepackage{soul}
\usepackage[utf8]{inputenc}
\usepackage{subfiles}
%\bibliographystyle{aea}
\usepackage[backend=biber,style=authoryear,sorting=nyvt]{biblatex}
\addbibresource{newbib3.bib}
\begin{document}
\noindent\textbf{Analysis of Editing}\\
\noindent{Substantive}: 0,-2.\\
Further: the,mighty.\\
\begin{tabular}{@{}l@{\ }l}
Value Added: & Yes,I want the benefit of using the tabular environment.\\
& No,because I would like this text to wrap automatically (instead of extending out continuously) and to be justified.
\end{tabular}
\end{document}
会产生以下内容:
编辑分析
实质:0,-2。
进一步:强大。
增值:是的,我想要使用表格环境的好处。
不,因为我希望这段文字能自动换行(而不是连续扩展)并证明其合理性。
解决方法
您可以使用固定宽度的列,例如p{5cm}
或tabularx
会自动调整X
列的宽度以填充所需的内容。
无关的注释:请不要滥用\\
来代替表格外的换行符
\documentclass[11pt,fleqn]{book}
\usepackage{import}
\usepackage{fancyhdr}
\fancyhf{}
\cfoot{\thepage}
\pagestyle{fancy}
\usepackage{soul}
\usepackage[utf8]{inputenc}
\usepackage{subfiles}
%\bibliographystyle{aea}
\usepackage[backend=biber,style=authoryear,sorting=nyvt]{biblatex}
\addbibresource{newbib3.bib}
\usepackage{tabularx}
\begin{document}
\noindent\textbf{Analysis of Editing}
\noindent{Substantive}: 0,-2.
Further: the,mighty.
\begin{tabularx}{.953\linewidth}{@{}l@{\ }X}
Value Added: & Yes,I want the benefit of using the tabular environment.\\
& No,because I would like this text to wrap automatically (instead of extending out continuously) and to be justified.
\end{tabularx}
\end{document}