我正在尝试改变\documentclass{report}
我为工作准备的包裹的标题页的显示方式。我已经拼凑了足够的知识来做到这一点很接近我想要的,但是现在我陷入困境。
一位 MWE 表示:
\documentclass{report}
\usepackage{lipsum}
\usepackage{showframe}
\title{An exceptionally long title that probably needs to look better than it does, and will span multiple lines}
\author{Company!\\Street!\\City!, State! ZIP!}
\makeatletter
\renewcommand{\maketitle}{\begin{titlepage}
\let\footnotesize\small
\let\footnoterule\relax
\let \footnote \thanks
\begin{flushleft}
\includegraphics[width=10cm]{example-image-a}
\end{flushleft}
\vfill
\begin{flushright}
{\LARGE \@title}
\vskip 3em
{\large
\lineskip .75em
\begin{tabular}[t]{l}
\@author
\end{tabular}\par}
\vskip 1.5em
\end{flushright}
\end{titlepage}
}
\makeatother
\begin{document}
\maketitle
\section{Lorem Ipsum}
\lipsum[1-3]
\end{document}
但我希望标题与地址一致。我尝试将标题放入环境中\tabular
,但事情变得混乱,我不断调整也无法解决它。
我怎样才能让标题——无论标题长度如何——与正确的地址的边缘?
答案1
为了保持标题和作者之间的适当对齐,请将其设置为tabular
具有单列且l
向左对齐的相同内容(通过 删除右侧的列间间隙@{}
):
\documentclass{report}
\usepackage{lipsum,graphicx}
\usepackage{showframe}
\title{Brief article with a very long title}
\author{Company! \\ Street! \\ City!, State! ZIP!}
\makeatletter
\renewcommand{\maketitle}{%
\begin{titlepage}
\let\footnotesize\small
\let\footnoterule\relax
\let\footnote\thanks
\noindent \includegraphics[width=10cm]{example-image}
\vfill
\noindent{\raggedleft\LARGE \@title\par}
\bigskip
\mbox{}\hfill
{\large\begin{tabular}{l@{}}
\@author
\end{tabular}}
\vspace{1.5em}
\end{titlepage}
}
\makeatother
\begin{document}
\maketitle
\section{Lorem Ipsum}
\lipsum[1-3]
\end{document}
标题使用 进行设置\raggedleft
,允许其在需要时延伸至整个标题页,并根据需要进行粗糙包装。
无需额外的包即可在页面上向左/向右移动内容。要么将其设置在\raggedright
/\raggedleft
段落内,要么通过 向右移动内容\mbox{}\hfill<stuff>
。\mbox{}
设置一个不包含任何内容的“标记”,从该标记\hfill
可以延伸到页面的右侧。
答案2
\documentclass{report}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{showframe}
\title{Brief Article}
\author{Company!\\Street!\\City!, State! ZIP!}
\makeatletter
\renewcommand{\maketitle}{%
\begin{titlepage}
\let\footnotesize\small%
\let\footnoterule\relax%
\let\footnote\thanks%
\begin{flushleft}%
\includegraphics[width=10cm]{example-image-a}%
\end{flushleft}%
\vfill%
\begin{flushright}
{\large%
\begin{tabular}[t]{l}
\LARGE\@title \\
\tabularnewline[.75em]%
\@author%
\end{tabular}%
}%
\vskip1.5em%
\end{flushright}%
\end{titlepage}%
}
\makeatother
\begin{document}
\maketitle%
\section{Lorem Ipsum}
\lipsum[1-3]
\end{document}
flushright
不带and 的版本flushleft
:
\documentclass{report}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{ragged2e}
\usepackage{showframe}
\title{A long stupid title that should not be there!}
\author{Company!\\Street!\\City!, State! ZIP!}
\makeatletter
\renewcommand{\maketitle}{%
\begin{titlepage}
\let\footnotesize\small%
\let\footnoterule\relax%
\let\footnote\thanks%
{%
\RaggedRight
\includegraphics[width=10cm]{example-image-a}%
}
\vfill%
{%
\RaggedLeft
{\large%
\begin{tabular}[t]{p{0.3\textwidth}}
\LARGE\@title \\
\tabularnewline[.75em]
\@author
\end{tabular}%
}%
\vskip1.5em
}%
\end{titlepage}%
}
\makeatother
\begin{document}
\maketitle%
\section{Lorem Ipsum}
\lipsum[1-3]
\end{document}