[Tex/LaTex] align offset text and margin note

horizontal alignmentmarginnotemargins

I'm creating some text with right aligned margin note and I want to make left margin space the same as the right margin space.

My idea to align:

set \pageLeftMargin to \pageRightMargin + \marginNoteLength + \myMarginparSep

\newlength{\marginNoteLength}
\settowidth{\marginNoteLength}{1903 - 1908}

\newcommand{\myMarginparSep}{20pt}
\newcommand{\pageRightMargin}{0in}

\newlength{\pageLeftMargin}
\setlength{\pageLeftMargin}{\dimexpr(\pageRightMargin+\marginNoteLength+\myMarginparSep)\relax}

\newlength{\marginoffset}
\setlength{\marginoffset}{\dimexpr(\pageLeftMargin-\pageRightMargin)\relax}

\geometry{
    left=\pageLeftMargin,
    top=1in,
    right=\pageRightMargin,
    bottom=1in,
    marginparsep=\myMarginparSep,
    marginparwidth=10in,
}

But as turned out, it doesn't work: right margin is zero while left margin is not.

How do I fix it?

enter image description here

%!TEX TS-program = lualatex
%!TEX encoding = UTF-8 Unicode

\documentclass[10pt]{article}

% DOCUMENT LAYOUT
\usepackage{enumitem, geometry, calc}

\newlength{\marginNoteLength}
\settowidth{\marginNoteLength}{1903 - 1908}

\newcommand{\myMarginparSep}{20pt}
\newcommand{\pageRightMargin}{0in}

\newlength{\pageLeftMargin}
\setlength{\pageLeftMargin}{\dimexpr(\pageRightMargin+\marginNoteLength+\myMarginparSep)\relax}

\newlength{\marginoffset}
\setlength{\marginoffset}{\dimexpr(\pageLeftMargin-\pageRightMargin)\relax}

\geometry{
    left=\pageLeftMargin,
    top=1in,
    right=\pageRightMargin,
    bottom=1in,
    marginparsep=\myMarginparSep,
    marginparwidth=10in,
}

\usepackage{luatexja-fontspec}
\setmainfont[Numbers=OldStyle]{Linux Libertine}

\usepackage{marginnote}
\newcommand{\marginNote}[1]{\mbox{}\marginnote{\hfill \normalsize #1}}
\renewcommand*{\raggedleftmarginnote}{}
\reversemarginpar

\begin{document}
\centerline{\tikz{\draw[-] (0,0)--(29.9,0);
    \foreach \i in {0,0.1,...,29.8}{\node (\i) at (\i,0) {$|$};}
    }
}
\marginNote{1908 - 1911} \hfill University of Bern\\
\marginNote{1911 - 1912} \hfill University of Zürich\\
\marginNote{1912 - 1914} \hfill Charles University of Prague\\
\marginNote{1914 - 1932} \hfill Prussian Academy of Sciences, Berlin\\
\marginNote{1920 - 1930} \hfill University of Leiden\\
\marginNote{1932 - 1955} \hfill Institute for Advanced Study, Princeton

\end{document}

Best Answer

I'm trying to understand/reproduce your problem. When I run your code with one additional horizontal bar,

\documentclass[10pt]{article}

\usepackage{geometry,lipsum}
\usepackage{calc}
\usepackage{tikz}

\newlength{\marginNoteLength}
\settowidth{\marginNoteLength}{random marginnote}

\newcommand{\myMarginparSep}{20pt}
\newcommand{\pageRightMargin}{1.1in}

\newlength{\pageLeftMargin}
\setlength{\pageLeftMargin}{\dimexpr(\pageRightMargin+\marginNoteLength+\myMarginparSep)\relax}

\geometry{
    left=\pageLeftMargin,
    top=1in,
    right=\pageRightMargin,
    bottom=1in,
    marginparsep=\myMarginparSep,
    marginparwidth=10in,
}

\usepackage{marginnote}
\newcommand{\marginNote}[1]{\mbox{}\marginnote{\hfill \normalsize #1}}
\renewcommand*{\raggedleftmarginnote}{}
\reversemarginpar

\thispagestyle{empty}
\setlength\parindent{0in}
\begin{document}
\centerline{\tikz{\draw[-] (0,0)--(29.9,0);
\foreach \i in {0,0.1,...,29.8}{\node (\i) at (\i,0) {$|$};}
\foreach \i in {0,1,...,29}{\node (\i) at (\i,0) {\Huge$|$};}}}

\marginNote{random marginnote}\lipsum[1-1]
{\vspace*{5pt}}
\marginNote{random marginnote}\lipsum[1-1]
{\vspace*{5pt}}
\marginNote{random marginnote}\lipsum[1-1]

\end{document}

I get

enter image description here

Could you please tell me which distance is inconsistent?

Related Question