\leftskip 之后 \marginnote 和内容之间的间隙变小

\leftskip 之后 \marginnote 和内容之间的间隙变小
\documentclass[10pt]{article}
\usepackage{geometry}
\geometry{left=1.5in,top=0.5in,right=1.5in,bottom=0.8in, marginparsep=1pt, marginparwidth=1in}

\usepackage{marginnote}
\newcommand{\years}[1]{{\setlength{\marginparwidth}{2.5in}\marginnote{\normalsize #1}}}
\renewcommand*{\raggedleftmarginnote}{}
\reversemarginpar


\begin{document}
\leftskip1in
{\LARGE Albert Einstein}\\[1cm]

\section*{Appointments held}
\noindent
\years{1903 - 1908}Swiss Patent Office, Bern\\
\years{1908 - 1911}University of Bern\\
\years{1911 - 1912}University of Zürich\\
\years{1912 - 1914}Charles University of Prague\\
\years{1914 - 1932}Prussian Academy of Sciences, Berlin\\
\years{1920 - 1930}University of Leiden\\
\years{1932 - 1955}Institute for Advanced Study, Princeton

\end{document}

在此处输入图片描述

正如你所看到的,边注离内容太远了,我希望间隙小一点。所以我设置\marginparwidth1.5in

\newcommand{\years}[1]{{\setlength{\marginparwidth}{1.5in}\marginnote{\normalsize #1}}}

我现在有 在此处输入图片描述

我如何解决它?

答案1

由于您打算覆盖文本区域,因此您应该使用\rlap。您真的想要吗\marginparsep=1pt

\documentclass[10pt]{article}
\usepackage{geometry}
\geometry{left=1.5in,top=0.5in,right=1.5in,bottom=0.8in, marginparsep=1pt, marginparwidth=1in}

\usepackage{marginnote}
\newcommand{\years}[1]{\marginnote{\rlap{\parbox[t]{\dimexpr\marginparwidth+\leftskip}%
  {\raggedleft\normalsize #1}}}}
%\renewcommand*{\raggedleftmarginnote}{}
\reversemarginpar


\begin{document}
\leftskip1in
{\LARGE Albert Einstein}\\[1cm]

\section*{Appointments held}
\noindent
\years{1903 - 1908}Swiss Patent Office, Bern\\
\years{1908 - 1911}University of Bern\\
\years{1911 - 1912}University of Zürich\\
\years{1912 - 1914}Charles University of Prague\\
\years{1914 - 1932}Prussian Academy of Sciences, Berlin\\
\years{1920 - 1930}University of Leiden\\
\years{1932 - 1955}Institute for Advanced Study, Princeton

\end{document}

演示

答案2

您使用了错误的工具。

\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\geometry{left=1.5in,top=0.5in,right=1.5in,bottom=0.8in,showframe}

\usepackage{titlesec}

\setcounter{secnumdepth}{-2} % no section number

\titleformat{\section}[block]
  {\Large\bfseries}
  {}
  {0pt}
  {\hspace*{1in}}

\newcommand{\years}[1]{%
  \par\noindent
  \makebox[1in][l]{#1}%
  \ignorespaces
}


\begin{document}

\noindent\hspace*{1in}{\LARGE Albert Einstein}

\vspace{1cm}

\section{Appointments held}
\years{1903--1908} Swiss Patent Office, Bern
\years{1908--1911} University of Bern
\years{1911--1912} University of Zürich
\years{1912--1914} Charles University of Prague
\years{1914--1932} Prussian Academy of Sciences, Berlin
\years{1920--1930} University of Leiden
\years{1932--1955} Institute for Advanced Study, Princeton

\end{document}

showframe选项仅用于显示文本块边距。

在此处输入图片描述

如果您希望年份更接近文本,请将定义更改\years为类似

\newcommand{\years}[1]{%
  \par\noindent
  \makebox[1in][r]{#1\quad}%
  \ignorespaces
}

在此处输入图片描述

相关内容