我正在编写一个程序来将 wikimarkup 解析为 LaTeX,在创建表格时遇到了一点问题。由于某种原因,表格的右侧垂直边缘被推到了右边距,并且一些中心边框也重复了。
我尝试从最右边的单元格中删除文本,看看文本是否以某种方式推过边框,但似乎没有什么区别。我还尝试\textwidth
手动设置为正确的值,但仍然没有成功。
这是完整的 LaTeX 代码:
\documentclass[letterpaper]{article}
\pagestyle{empty}
\usepackage[utf8]{inputenc}
\usepackage[margin=4cm]{geometry}
\usepackage{libertine, parskip, setspace, tabularx, tikz, ulem, wasysym}
\usepackage[T1]{fontenc}
\setlength\parindent{0pt}
\newcommand{\hfline}[3]{%
\par\medskip\noindent
\makebox[\textwidth][s]{\rlap{#1}\hfill#2\hfill\llap{\footnotesize{#3}}}%
\par\medskip}
\begin{document}
\begin{spacing}{0.7}
\begin{center}
\begin{scriptsize}\textbf{Declassified} per Executive Order 13526, Section 3.3\\NND Project Number: NND 63316.By: NWD Date: 2011
\end{scriptsize}
\end{center}
\end{spacing}
\begin{center}
\begin{large}
FINAL REPORT OSD \\
\end{large}
\begin{large}
Vietnam Task Force \& Index \\
\end{large}
\end{center}
\newpage
\begin{spacing}{0.7}
\begin{center}
\begin{scriptsize}\textbf{Declassified} per Executive Order 13526, Section 3.3\\NND Project Number: NND 63316.By: NWD Date: 2011
\end{scriptsize}
\end{center}
\end{spacing}
\begin{center}
\begin{Large}
EXECUTIVE SECRETARIAT \\
\end{Large}
\end{center}
\begin{tabularx}{0.7\textwidth}{X X X X X}
TLE & JJ & RMM & KDA & \fbox{ S/S-A} \\
& & & & \\
RHM & AL & LA & NP & S/S-I \\
& & & & S/S-O \\
RTC & HHB & BF & PW & S/S-S \\
& & & & \\
JC & TMT & JM & \fbox{ HCB} & S/S-EX \\
\end{tabularx} \\
\rule{\textwidth}{2px} \\
\begin{tabularx}{\textwidth}{X X}
\begin{large}\Square~ ACTION\end{large} & \begin{large}\Square~ INFORMATION\end{large} \\
\begin{large}\Square~ COMMENTS PLEASE\end{large} & \begin{large}\Square~ YOUR FILES\end{large} \\
\begin{large}\Square~ FOLLOW UP\end{large} & \begin{large}\Square~ PER CONVERSATION\end{large} \\
\begin{large}\CheckedBox~ PLEASE SEE/\sout{CALL ME}\end{large} & \begin{large}\Square~\end{large} \\
\end{tabularx} \\
\rule{\textwidth}{2px} \\
\begin{large}
REMARKS \\
\end{large}
\begin{center}
\begin{large}
Any S/S involvement? \\
\end{large}
\end{center}
\begin{flushright}
RTC
\end{flushright}
\rule{\textwidth}{2px} \\
\begin{tabularx}{\textwidth}{X X X}
T. L. ELIOT, JR. & R. H. MILLER & R. T. CURRAN \\
X22540 & X23126 & X28448 \\
\end{tabularx} \\
\newpage
\begin{spacing}{0.7}
\begin{center}
\begin{scriptsize}\textbf{Declassified} per Executive Order 13526, Section 3.3\\NND Project Number: NND 63316.By: NWD Date: 2011
\end{scriptsize}
\end{center}
\end{spacing}
\begin{flushright}
SecDef/CCS Regrading Action \#35---71
\end{flushright}
\begin{tabularx}{\textwidth}{*{4}{|p{0.25\textwidth}|}}
\hline
\multicolumn{2}{|p{0.5\textwidth}|}{\textbf{OFFICE OF THE SECRETARY OF DEFENSE REGRADING ACTION}} & \multicolumn{2}{|p{0.5\textwidth}|}{\textbf{\begin{footnotesize}DATE\end{footnotesize}} \newline \newline 23 June 1971} \\ \hline
\multicolumn{4}{|p{1.0\textwidth}|}{\textbf{\begin{footnotesize}FROM:\end{footnotesize}} \newline Top Secret Control Officer, SecDef/Classified Control Section, Room 31948, The Pentagon, Washington, D. C. 20301} \\ \hline
\multicolumn{4}{|p{1.0\textwidth}|}{\textbf{\begin{footnotesize}TO:\end{footnotesize}} \newline State Department, ATTENTION: Document Control/Security Officer, Washington, D. C. 20520} \\ \hline
\textbf{\begin{footnotesize}DOCUMENT\end{footnotesize}} \newline \textbf{\begin{footnotesize}(Type, Office of Origin, Date, Subject)\end{footnotesize}} & \textbf{\begin{footnotesize}CONTROL NUMBER\end{footnotesize}} & \textbf{\begin{footnotesize}CLASSIFICATION\end{footnotesize}} & \textbf{\begin{footnotesize}REGRADED TO\end{footnotesize}} \\ \hline
Memorandum for the Secretary of Defense, Thru: ASD/ISA and DASD(Policy Planning and Arms Control), OASD(ISA), From Chairman, OSD Task Force /s/ Leslie H. Gelb, dated 15 January 1969, Subject: Final Report, OSD Vietnam Task Force (U) w/1 Inclosure::::::::: & SecDefControl\#X-0295/69 & CONFIDENTIAL & UNCLASSIFIED WHEN SEPARATED FROM INCLOSURE \\ \hline
\textit{INCLOSURE \# 1:} \newline Document, Subject: OSD Vietnam Task Force Outline of Studies (U), dtd 10 January 1969----------------------- & " & CONFIDENTIAL & REMAINS CONFIDENTIAL \\ \hline
\multicolumn{4}{|p{1.0\textwidth}|}{////////NOTHING FOLLOWS//////////// \newline \newline \newline Document was forwarded to both Mr. Bundy and Mr. Katzenback in 1969 \newline If you have any questions concerning this regrading action please contact SFC William C. Holzer, US Army, Chief Clerk, SecDef/Classified Control Section, Rm3A948, The Pentagon, Phone: OX-76131 \newline \newline \newline Done 7/19/71 \newline Copy in EA/Bundy file \newline Copy in 8/1-file 7512 \newline \newline \newline } \\ \hline
\multicolumn{4}{|p{1.0\textwidth}|}{\begin{footnotesize}The document(s) listed above has/have been regraded and action should be taken to mark copies furnished your office. It is requested that you notify all recipients to whom additional distribution was furnished.\end{footnotesize} \newline \newline \newline } \\ \hline
\multicolumn{2}{|p{0.5\textwidth}|}{\textit{T. B. EDWARDS, MAJ, USA, Top Secret Control Officer} \newline \begin{footnotesize}Printed or typed name of official\end{footnotesize}} & \multicolumn{2}{|p{0.5\textwidth}|}{\begin{footnotesize}Signature\end{footnotesize}} \\ \hline
\end{tabularx} \\
\end{document}
有问题的表格跨越第 97-108 行。该表格(第 4 页)如下所示:
答案1
尽管由于内容原因仍然存在一些行距问题,但以下内容应该可以帮助您:
\documentclass{article}
%\usepackage[showframe]{geometry}% http://ctan.org/pkg/geometry
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\begin{document}
\begin{tabularx}{\textwidth}{*{4}{|p{0.25\textwidth}|}}
\hline
\multicolumn{2}{|p{0.5\textwidth}|}{\textbf{OFFICE OF THE SECRETARY OF DEFENSE REGRADING ACTION}} & \multicolumn{2}{|p{0.5\textwidth}|}{\textbf{\begin{footnotesize}DATE\end{footnotesize}} \newline \newline 23 June 1971} \\ \hline
\multicolumn{4}{|p{1.0\textwidth}|}{\textbf{\begin{footnotesize}FROM:\end{footnotesize}} \newline Top Secret Control Officer, SecDef/Classified Control Section, Room 31948, The Pentagon, Washington, D. C. 20301} \\ \hline
\textbf{\begin{footnotesize}DOCUMENT\end{footnotesize}} \newline \textbf{\begin{footnotesize}(Type, Office of Origin, Date, Subject)\end{footnotesize}} & \textbf{\begin{footnotesize}CONTROL NUMBER\end{footnotesize}} & \textbf{\begin{footnotesize}CLASSIFICATION\end{footnotesize}} & \textbf{\begin{footnotesize}REGRADED TO\end{footnotesize}} \\ \hline
Memorandum for the Secretary of Defense, Thru: ASD/ISA and DASD(Policy Planning and Arms Control), OASD(ISA), From Chairman, OSD Task Force /s/ Leslie H. Gelb, dated 15 January 1969, Subject: Final Report, OSD Vietnam Task Force (U) w/1 Inclosure::::::::: & SecDefControl\#X-0295/69 & CONFIDENTIAL & UNCLASSIFIED WHEN SEPARATED FROM INCLOSURE \\ \hline
\end{tabularx}
\newpage
\noindent
\begin{tabularx}{\textwidth}{|*{4}{X|}}
\hline
\multicolumn{2}{|p{\dimexpr0.5\linewidth-2\tabcolsep-2\arrayrulewidth}|}
{\textbf{OFFICE OF THE SECRETARY OF DEFENSE REGRADING ACTION}} &
\multicolumn{2}{p{\dimexpr0.5\linewidth-2\tabcolsep-\arrayrulewidth}|}
{\textbf{\footnotesize DATE} \newline \newline 23 June 1971} \\
\hline
\multicolumn{4}{|p{\dimexpr\linewidth-2\tabcolsep-2\arrayrulewidth}|}{\textbf{\begin{footnotesize}FROM:\end{footnotesize}} \newline Top Secret Control Officer, SecDef/Classified Control Section, Room 31948, The Pentagon, Washington, D. C. 20301} \\
\hline
\textbf{\footnotesize DOCUMENT} \newline
\textbf{\footnotesize (Type, Office of Origin, Date, Subject)} &
\textbf{\footnotesize CONTROL NUMBER} &
\textbf{\footnotesize CLASSIFICATION} &
\textbf{\footnotesize REGRADED TO} \\
\hline
Memorandum for the Secretary of Defense, Thru: ASD/ISA and DASD(Policy Planning and Arms Control), OASD(ISA), From Chairman, OSD Task Force /s/ Leslie H. Gelb, dated 15 January 1969, Subject: Final Report, OSD Vietnam Task Force (U) w/1 Inclosure::::::::: & SecDefControl\#X-0295/69 &
CONFIDENTIAL &
UNCLASSIFIED WHEN SEPARATED FROM INCLOSURE \\
\hline
\end{tabularx}
\end{document}
与您的表格相比,以下是我实施的更改的一些亮点:
tabularx
实现一种X
列类型,该列类型会根据其他列和给定的宽度进行拉伸以填充表格中的剩余空间tabularx
。使用它。\noindent
阻止表格被推到右侧,因为它是段落中的第一个元素,这通常需要缩进。当然,如果您设置\parindent
为0pt
,这并不重要,但这只是一般建议。手动设置宽度的每列都必须精确计算,以适应边距。因此,每列由 2 条规则(宽度
\arrayrulewidth
)、2 条列分隔/间隙(宽度\tabcolsep
)以及物理列宽组成。因此,为了跨度\multicolumn
为 2 列且两侧各有一条规则,请使用\multicolumn{2}{|p{\dimexpr0.5\linewidth-2\tabcolsep-2\arrayrulewidth}|}{...}
将会起作用,因为物理宽度(从一条规则到下一条规则)是0.5\linewidth
。
在我的例子中,第二个\multicolumn
不仅仅使用单个\arrayrulewidth
。这是因为第一个\arrayrulewidth
构成了第一个列集的一部分。- 使用\footnotesize
而不是环境;在这种情况下,这不是必需的。
这geometry
包中加载了showframe
突出显示文本块边界的选项。