我想知道是否可以在同一行上放置两段文本,既左对齐又右对齐。
例如这样做:
{\itshape{\begin{flushleft}I'm on the left\end{flushleft}\begin{flushright}I'm on the right\end{flushright}}
最终看起来像这样:
I'm on the left
I'm on the right
我怎样才能使它看起来像这样?:
I'm on the left I'm on the right
答案1
这最终解决了我的问题:)
\newcommand{\restitle}[2]{%
\par\medskip\noindent
\makebox[0pt][l]{\itshape\normalsize{#1}}%
\makebox[\textwidth][r]{\itshape\normalsize{#2}}}
用法:\restitle{I'm on the left}{I'm on the right}
输出:I'm on the left I'm on the right
答案2
只需使用拉伸框:
\documentclass{article}
\usepackage{showframe} % just for the example
\newcommand{\restitle}[2]{%
\begin{flushleft}% makes for vertical spacing and kills indent
\makebox[\textwidth][s]{#1\hfil#2}%
\end{flushleft}
}
\begin{document}
\restitle{I'm on the left}{I'm on the right}
\restitle{Again left}{Again right}
\end{document}