如何去除表格后的空格,并通过 \hfill 将其右对齐?

如何去除表格后的空格,并通过 \hfill 将其右对齐?

我想摆脱右侧\begin{tabular}{ll} \textsc{place,} & \textsc{date}\\ Place, & \today \end{tabular} %和右页边距/边框之间的额外空白:

在此处输入图片描述

我承认这个标题不是最好的,如果有人知道更好的标题,请随意编辑它和这一行。

平均能量损失

\documentclass[
fontsize=12pt,
a4paper,
DIV=15,
parskip=half
]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{
lmodern,
lipsum
}

\listfiles

\begin{document}
%\vspace{0.5cm}
\begin{flushleft}
Words\\
More Words
\end{flushleft}%
\begin{tabular}{@{}l}
\textsc{code}\\
11-22-33-44
\end{tabular}%
\hfill
\begin{tabular}{ll}
\textsc{place,} & \textsc{date}\\
Place, & \today
\end{tabular}
\begin{flushleft}
\bfseries Words
\end{flushleft}
\begin{flushleft}
Something,
\end{flushleft}
\lipsum[3]
\end{document}

答案1

您需要一个l@{},这样文本右侧就没有 tabcolsep 填充(就像您已经在其他表格的左边距使用的那样)。然后,您需要确保\hfill没有通过添加到段落最后一行的粘合来平衡\parfillskip。因为您希望两边都有相同的效果,所以center这是一个合适的环境。

在此处输入图片描述

\documentclass[
fontsize=12pt,
a4paper,
DIV=15,
parskip=half
]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{
lmodern,
lipsum
}

\listfiles

\begin{document}
\begin{flushleft}
Words\\
More Words
\end{flushleft}%
\begin{center}
\noindent\begin{tabular}{@{}l}
\textsc{code}\\
11-22-33-44
\end{tabular}%
\hfill
\begin{tabular}{ll@{}}
\textsc{place,} & \textsc{date}\\
Place, & \today
\end{tabular}
\end{center}
\begin{flushleft}
\bfseries Words
\end{flushleft}
\begin{flushleft}
Something,
\end{flushleft}
\lipsum[3]
\end{document}

答案2

玩了一下,发现

\begin{tabular}{ll@{}}
\textsc{place,} & \textsc{date}\\
Place, & \today
\end{tabular}\\

有效。 =>平均能量损失

\documentclass[
fontsize=12pt,
a4paper,
DIV=15,
parskip=half
]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{
lmodern,
lipsum
}

\listfiles

\begin{document}
\begin{flushleft}
Words\\
More Words
\end{flushleft}%
\noindent\begin{tabular}{@{}l}
\textsc{code}\\
11-22-33-44
\end{tabular}%
\hfill
\begin{tabular}{ll@{}}
\textsc{place,} & \textsc{date}\\
Place, & \today
\end{tabular}\\
\begin{flushleft}
\bfseries Words
\end{flushleft}
\begin{flushleft}
Something,
\end{flushleft}
\lipsum[3]
\end{document}

很高兴看到其他答案,也许这不是唯一/最好的解决方案。

相关内容