将文本放在顶行,每个段落右对齐

将文本放在顶行,每个段落右对齐

我正在写简历,我想把活动 xyz 的年份放在每段的右上角。通常,我会使用 \hfill,但对于较长的条目,年份会溢出下一行,而我更希望每项活动的文本描述换行。

    \section{\textnormal{\textbf{RANDO}}}
    \emph{HONOR HONOR HONOR} used for study in Harvard University's Business            
    Economics Program \hfill 2016-present \\ [0.1cm]
    \emph{HONOR HONOR HONOR 2} for Yale University's doctorate in finance           
    (declined) \hfill 2016

我想要的是保证每个日期都位于页面右侧其段落的顶行。

答案1

如果您使用特殊的\documentclass,则可能需要放大\marginparwidth

\documentclass{article}
\begin{document}
\section{\textnormal{\textbf{RANDO}}}\leavevmode
    \marginpar{\hfill 2016-present}%
    \emph{HONOR HONOR HONOR} used for study in Harvard University's Business            
    Economics Program\\[0.1cm]
    \marginpar{\hfill 2016}%
    \emph{HONOR HONOR HONOR 2} for Yale University's doctorate in finance           
    (declined)
\end{document}

您还可以使用 tabularx:

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\section{\textnormal{\textbf{RANDO}}}
\begin{tabularx}{\textwidth}{@{}Xp{1in}@{}}
    \emph{HONOR HONOR HONOR} used for study in Harvard University's Business            
    Economics Program & 2016-present \\[0.1cm]
    \emph{HONOR HONOR HONOR 2} for Yale University's doctorate in finance           
    (declined) & 2016
\end{tabularx}
\end{document}

您可以使用 使文本围绕日期流动\hangindent。为了方便起见,我创建了长度\datewidth和宏\myformat

\documentclass{article}
\usepackage{blindtext}

\newlength{\datewidth}
\setlength{\datewidth}{1in}

\newcommand{\myformat}[1]% #1 = date field
{\par\hangindent=-\datewidth
 \hangafter=-1
 \noindent\rlap{\hspace{\dimexpr \textwidth-\datewidth}\makebox[\datewidth][r]{#1}}%
}
\begin{document}
\section{\textnormal{\textbf{RANDO}}}
    \myformat{2016-present}%
    \emph{HONOR HONOR HONOR} used for study in Harvard University's Business            
    Economics Program \blindtext
    \vspace{0.1cm}\myformat{2016}%
    \emph{HONOR HONOR HONOR 2} for Yale University's doctorate in finance           
    (declined)
\end{document}

此变体使用可变宽度的日期字段。

\documentclass{article}
\usepackage{blindtext}

\newsavebox{\datebox}% \hangindent global

\newcommand{\myformat}[1]% #1 = date field
{\savebox{\datebox}{\hspace{1em}\textbf{#1}}%
  \par\hangindent=-\wd\datebox
  \hangafter=-1
  \noindent\rlap{\hspace{\dimexpr \linewidth-\wd\datebox}\usebox{\datebox}}%
}
\begin{document}
\section{\textnormal{\textbf{RANDO}}}
    \myformat{2016-present}%
    \emph{HONOR HONOR HONOR} used for study in Harvard University's Business            
    Economics Program \blindtext
    \vspace{0.1cm}\myformat{2016}%
    \emph{HONOR HONOR HONOR 2} for Yale University's doctorate in finance           
    (declined)
\end{document}

相关内容