
如果我使用以下 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}
結果: