3

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}
1

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?

  • Thanks for your answer. I just edit a bit to make it more clear. – Rahn Dec 10 '17 at 8:48
1

Found the problem:

I calculate \marginNoteLength before setting font. I should have done it after font setting.

Length of 1234567890 before font setting: 50.00015pt
Length of 1234567890 after font setting:  46.48438pt

enter image description here

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

\documentclass[10pt]{article}

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

\newlength{\lenBeforeFontSetting}
\settowidth{\lenBeforeFontSetting}{1234567890}

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

\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,
}


\newlength{\lenAfterFontSetting}
\settowidth{\lenAfterFontSetting}{1234567890}

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

\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) {$|$};}
    }
}

\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

\vspace*{30pt}

Length of 1234567890 before font setting: \the\lenBeforeFontSetting\\
Length of 1234567890 after font setting: \the\lenAfterFontSetting

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.