如果我使用以下 scrreprt 文档,初始 tabularx 表与文本区域的左边界对齐:
\documentclass[draft=true]{scrreprt}
\usepackage{tabularx}
\usepackage{xifthen}
\usepackage{showframe}
\newcommand*{\BTDTitleTable}{%
\noindent%
\begin{tabularx}{\textwidth}{|p{0.14\textwidth}|p{0.14\textwidth}|X|p{0.14\textwidth}|p{0.14\textwidth}|}%
\hline%
a%
& b%
& c%
& d%
& f \\%
\hline%
1%
& 2%
& 3%
& 4%
& 5 \\%
\hline%
\end{tabularx}%
\par\vspace{0.6cm}%
}%
\newcommand*{\BTDSignatureAndDate}[3][Foobar]{%
\par\noindent\vspace{1.4cm}%
\par\noindent\makebox[0cm][l]{{\large {#1}:}}%
\par\noindent\vspace{0.6cm}%
\par\noindent\makebox[0.224\textwidth][l]{\hrulefill} \hfill\makebox[0.67\textwidth][l]{\hrulefill}%
\ifthenelse{\isempty{#3}}%
{\par\noindent\makebox[0.224\textwidth][l]{\small Date} \hfill\makebox[0.67\textwidth][l]{\small #2}}%
{\par\noindent\makebox[0.224\textwidth][l]{\small Date} \hfill\makebox[0.67\textwidth][l]{\small #2, #3}}%
}%
\KOMAoption{twoside}{true}
\begin{document}
\pagestyle{empty}
\BTDTitleTable
\BTDSignatureAndDate{Foobar}{Foo Baz}
\end{document}
这会产生以下 pdf 片段(均使用 xelatex 和 pdflatex):
用以下代码替换上述文档,同时保留几乎相同的前言(我不得不将表格宽度更改为“0.99\textwidth”以避免警告):
\begin{document}
\extratitle{
\BTDTitleTable
\BTDSignatureAndDate{Foobar}{Foo Baz}
}
\title{Not of interest}
\author{Foo bar}
\maketitle[-1]
\end{document}
生成以下 pdf 片段:
请注意表格左侧约 1% 文本宽度的额外缩进。
我该如何去掉这个额外的缩进?而且它为什么是由 \extratitle 添加的?
答案1
有一个额外的虚假空格(换行)。将其放在%
括号后面,\extratitle
例如 \extratitle{%
:
完整的示例(现在您可以使用完整的\textwidth
):
\documentclass[draft=true]{scrreprt}
\usepackage{tabularx}
\usepackage{xifthen}
\usepackage{showframe}
\newcommand*{\BTDTitleTable}{%
\noindent%
\begin{tabularx}{\textwidth}{|p{0.14\textwidth}|p{0.14\textwidth}|X|p{0.14\textwidth}|p{0.14\textwidth}|}%
\hline%
a%
& b%
& c%
& d%
& f \\%
\hline%
1%
& 2%
& 3%
& 4%
& 5 \\%
\hline%
\end{tabularx}%
\par\vspace{0.6cm}%
}%
\newcommand*{\BTDSignatureAndDate}[3][Foobar]{%
\par\noindent\vspace{1.4cm}%
\par\noindent\makebox[0cm][l]{{\large {#1}:}}%
\par\noindent\vspace{0.6cm}%
\par\noindent\makebox[0.224\textwidth][l]{\hrulefill} \hfill\makebox[0.67\textwidth][l]{\hrulefill}%
\ifthenelse{\isempty{#3}}%
{\par\noindent\makebox[0.224\textwidth][l]{\small Date} \hfill\makebox[0.67\textwidth][l]{\small #2}}%
{\par\noindent\makebox[0.224\textwidth][l]{\small Date} \hfill\makebox[0.67\textwidth][l]{\small #2, #3}}%
}%
\KOMAoption{twoside}{true}
\begin{document}
\extratitle{%
\BTDTitleTable
\BTDSignatureAndDate{Foobar}{Foo Baz}
}
\title{Not of interest}
\author{Foo bar}
\maketitle[-1]
\end{document}
结果: