# writing on the inner margin

I have some lecture notes where margin notes are used. Now I would like to mark some of the theorem or proofs as important. To to this I would like to add some "icon" (maybe just some star symbol) on the margin. Since notes are on the outer margin I would like to use the inner margin. I tried by using \reversemarginpar but with no success see MWE below. Sometimes the stars go on one margin sometimes on the other. Moreover I would like the stars to be aligned with the "Theorem" or "Proof" line, instead they are below or above.

Is there a way to put a box in the inner margin at an absolute horizontal position and at the current vertical position?

\documentclass[italian,a4paper,twoside,headinclude]{scrbook}
\usepackage{amsthm,thmtools}
\usepackage{babel,a4}
\usepackage[nochapters,pdfspacing]{classicthesis}
\usepackage[utf8]{inputenc}
\usepackage{sidenotes}
\usepackage{hyphenat}
\usepackage{mparhack} % fix margin notes (otherwise sometime they go to wrong margin!)

\newcommand{\mymark}[1]{\reversemarginpar\marginpar{#1}\normalmarginpar}

\newcommand{\mynote}[1]{\sidenote[\phantom{}]{#1}}
\newcommand{\mymargin}[1]{\mynote{#1}\index{#1}}

\declaretheorem[name=Teorema,numberwithin=chapter]{theorem}

\begin{document}
\begin{theorem}[Bolzano-Weierstrass]
\mymargin{Bolzano-Weierstrass}
\index{teorema!di Bolzano-Weierstrass}
\mymark{***}%
Se $a_n$ è limitata allora esiste una sottosuccessione
$a_{n_k}$ convergente.
\end{theorem}
%
\begin{proof}
\mymark{**}%
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
\end{proof}

\end{document}


The marginnote package will do this quite nicely. If I add \usepackage{marginnote} and make only these adjustments to your code:

\newcommand{\mymark}[1]{\reversemarginpar\marginnote{#1}\normalmarginpar}
\newcommand{\mymargin}[1]{\marginnote{{\footnotesize #1}}\index{#1}}


I get

## UPDATED

In the light of your comment, I looked again at what you are doing. Although it's working for you, I don't think sidenote is being used correctly here. I could go into detail, but in essence you will get poor spacing and various other problems.

I did a bit more thinking, and I am inclined to suggest an entirely different approach, since you are using komascript, namely the notecolumn. It requires two passes to get it right, but it is precisely designed to solve your problem, and it will shift notes if necessary as you wish.

Please note this always needs two compiles to get the notes right.

\documentclass[italian,a4paper,twoside,headinclude]{scrbook}
\usepackage{amsthm,thmtools}
\usepackage{babel,a4}
\usepackage[nochapters,pdfspacing]{classicthesis}
\usepackage[utf8]{inputenc}
\usepackage{scrlayer-scrpage}
\usepackage{scrlayer-notecolumn}
\DeclareNewNoteColumn[%
position={\ifodd\value{page}
\dimexpr \oddsidemargin+1in
-\marginparsep\relax
\else
\dimexpr \evensidemargin+1in
+\textwidth+\marginparsep\relax
\fi},
font=\raggedright\footnotesize\bfseries]{marker}
\RedeclareNoteColumn[%
marginpar,
font=\raggedright\footnotesize]{marginpar}

\newcommand{\mymarker}[1]{\makenote[marker]{#1}}
\newcommand{\mynote}[1]{\makenote[marginpar]{#1}\index{#1}}

\declaretheorem[name=Teorema,numberwithin=chapter]{theorem}

\begin{document}
\begin{theorem}[Bolzano-Weierstrass]\mynote{Bolzano-Weierstrass}\mymarker{***}
\index{teorema!di Bolzano-Weierstrass}
Se $a_n$ è limitata allora esiste una sottosuccessione
$a_{n_k}$ convergente.
\end{theorem}
\begin{proof}
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
\end{proof}

\end{document}


A note: I had thought that I could get the "marker" column as I wanted it simply by giving the option reversemarginpar to \DeclareNewNoteColumn. I couldn't. I think though I haven't dug too deeply that there is a bug in how this is defined, which is putting the note off the page on oddside pages. At any rate, what I have seems to work!

• Thanks! Actually I was using package sidenotes instead of marginnote because it is able to manage overlapping marginal notes. With your solution I get some margin notes overlapping elsewhere... – Emanuele Paolini May 2 '18 at 7:31

It may be a bit overkill, but you can use TikZ in overlay mode. The origin is placed at the baseline where the tikzpicture is used. It takes two runs for TikZ to figure out where the origin is relative to the rest of the page.

The tricky bit was aligning the first line of the text to the baseline. A node normally centers the text vertically (using left or right).

\documentclass[italian,a4paper,twoside,headinclude]{scrbook}
\usepackage{amsthm,thmtools}
\usepackage{babel,a4}
\usepackage[nochapters,pdfspacing]{classicthesis}
\usepackage[utf8]{inputenc}
\usepackage{hyphenat}
\usepackage{tikzpagenodes}

\makeatletter
\let\tikzpage=\oddpage@page
\makeatother

\newcommand{\mymark}[1]{\begin{tikzpicture}[remember picture,overlay]
\coordinate (here) at (0,0);
\ifodd\tikzpage
\path (current page text area.west |- here)
node[left=\marginparsep,inner sep=0pt] {#1};
\else
\path (current page text area.east |- here)
node[right=\marginparsep,inner sep=0pt] {#1};
\fi
\end{tikzpicture}}

\newcommand{\mynote}[1]{\begin{tikzpicture}[remember picture,overlay]
\coordinate (here) at (0,0);
\ifodd\tikzpage
\path (current page text area.east |- here)
node[right=\marginparsep,inner sep=0pt]
{\smash{\parbox[t]{\marginparwidth}{\raggedright #1}}};
\else
\path (current page text area.west |- here)
node[left=\marginparsep,inner sep=0pt]
{\smash{\parbox[t]{\marginparwidth}{\raggedright #1}}};
\fi
\end{tikzpicture}}

\newcommand{\mymargin}[1]{\mynote{#1}\index{#1}}

\declaretheorem[name=Teorema,numberwithin=chapter]{theorem}

\begin{document}
\begin{theorem}[Bolzano-Weierstrass]
\mymargin{Bolzano-Weierstrass}
\index{teorema!di Bolzano-Weierstrass}
\mymark{***}%
Se $a_n$ è limitata allora esiste una sottosuccessione
$a_{n_k}$ convergente.
\end{theorem}
%
\begin{proof}
\mymark{**}%
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
Questa è la dimostrazione.
\end{proof}

\end{document}