左、右對齊在同一直線上

左、右對齊在同一直線上

我目前正忙於排版我的論文LaTeX,但我的封面/扉頁被困在了一些東西上。在頁面底部,我需要輸入我的姓名和主管的姓名。

這是佈局的一個粗略想法(用 Word 編寫),我希望在其中排版我的名字和我的主管的名字。

在此輸入影像描述

但是,我不知道如何使我的名字在左側和我的主管的名字在右側進行左右對齊。

有人可以告訴我如何在 LaTeX 中排版類似的東西嗎?

答案1

您可以嘗試以下幾件事。一個簡單的技巧是使用\hfill,例如

\documentclass{article}
\begin{document}

\textbf{\underline{Student:}}
\hfill
\textbf{\underline{Supervisor:}} \\
Mr. Thatshisname
\hfill
Prof. Whatshisname

\end{document}

這將產生以下結果: 第一路

這並不能完全重現範例中所示的“Supervisor”一詞的間距。另一種方法可以更好地重現這一點,儘管它涉及更多。這\hfillminipage環境一起使用:

\documentclass{article}
\begin{document}

\begin{minipage}{2in}
\textbf{\underline{Student:}} \\
Mr. Thatshisname
\end{minipage}
\hfill
\begin{minipage}{1.3in}
\textbf{\underline{Supervisor:}} \\
Prof. Whatshisname
\end{minipage}

\end{document}

第一個的大小minipage並不重要,因為\hfill會填滿空間,但第二個的大小minipage需要調整,以使右邊緣盡可能接近邊距,而不會強制換行。我使用該showframe包使該過程變得更容易,但也許其他人有更優雅的解決方案。這是輸出:

第二路

為了將其顯示在頁面底部,您可以嘗試使用該\vfill命令。實現您正在尋找的結果的另一種方法是使用該fancyhdr套件(閱讀“花式標頭”):

\documentclass{article}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\usepackage{lipsum}

\pagestyle{fancy}
\lfoot{\textbf{\underline{Student:}} \\
    Mr. Thatshisname}
\rfoot{\textbf{\underline{Supervisor:}}
    \phantom{MMMi}\\
    Prof. Whatshisname}

\begin{document}
\lipsum[1-4]
\end{document}

這會將這些文字放置在每個頁面的底部,並帶有 pagestyle fancy。如果您只想將其顯示在第一頁上,請使用\thispagestyle{fancy}after\begin{document}而不是\pagestyle{fancy}如我的範例所示。我必須將 重新定義\headrulewidth為零,以便該行不會顯示在頁面頂部(如果有“更好”的方法來執行此操作,有人可以對此答案發表評論嗎?)。這個解決方案也有與第一個解決方案相同的問題,即“Supervisor”被一直推到了邊緣。但是,我使用該\phantom命令添加了一些空白,並修改了輸入以使其看起來正確。這是輸出:

第三條路

希望這可以幫助!

答案2

\begin{titlepage}
    ... whatever should be here ...
         for a titlepage

\vfill\noindent
\begin{tabular}[t]{@{}l} 
  \underline{\textbf{Student:}}\\  Mr. Thatshisname
\end{tabular}
\hfill% move it to the right
\begin{tabular}[t]{l@{}}
   \underline{\textbf{Supervisor:}}\\ Prof. Whatshisname
\end{tabular}
\end{titlepage}

在此輸入影像描述

答案3

這使用tabularx表格來使用整體\linewidth,並用(空!)列填充表格的其餘部分X

\documentclass{book}
\usepackage{tabularx}
\usepackage{showframe}

\newcommand{\headlinestyle}[1]{\large\textbf{#1}}
\newcommand{\namestyle}[1]{#1}

\begin{document}
\noindent\begin{tabularx}{\linewidth}{@{}p{4cm}Xp{4cm}@{}}
\headlinestyle{Student:} & & \headlinestyle{Supervisor:} \tabularnewline[0.5ex]
\namestyle{Mr. Gumby}    & & \namestyle{Prof. Gumby} \tabularnewline
\end{tabularx}


\end{document}

我故意刪除了下劃線——showframe當然可以省略包。

在此輸入影像描述

答案4

您確定要正確填寫主管姓名嗎?這裡更常見的是這樣的事情:

\documentclass{article}
\usepackage{showframe} % just to show the page boundaries
\begin{document}

whatever... 

\vfill
\noindent \parbox[t]{0.5\linewidth}{%
\underline{\textbf{Student}} \\ Mr. Studentname \\ \vspace{2cm} } % 
\parbox[t]{0.45\linewidth}{%
    \underline{\textbf{Supervisor}} \\ Mr. Supervisorname}

\end{document}

....在姓名下方有簽名位置,並與姓名左側齊平。

片段產生的輸出

相關內容