I am trying to set up a custom margin note command for my lecture notes but I encountered a few problems.
First of all, this is how it should look:
As you can see in the screenshot above, the margin notes are numbered (I tried to mimic footnotes).
First, I tried to use the marginpar
command. Sadly, it cannot be used in math environments as well as tcbtheorem
environments from the tcolorbox
package which I happen to use quite frequently.
After trying with marginpar
I ended up with the marginnote
package, which does work in math as well as tcbtheorem environments, but there are different problems. The biggest downside is, that margin notes from the marginnote
command overlap very easily and it's annoying to manually move them up and down until one finds the right spot.
What I am trying to achieve are numbered margin notes which can be referenced (used with the label/ref
commands), used in math as well as tcbtheorem environments and don't overlap (they should behave like margin notes from the marginpar
command, which automatically move up and down).
Is something like this achievable?
Minimal example (comment out mpar command to see errors):
\documentclass{article}
\usepackage[left=10mm,right=65mm,top=20mm,bottom=25mm,headheight=15pt]{geometry}
\usepackage{marginnote}
\usepackage[most]{tcolorbox}
\usepackage{blindtext}
\setlength{\marginparwidth}{50mm}
\setlength{\marginparsep}{5mm}
\newcounter{mnotecnt}
\renewcommand\themnotecnt{\textsuperscript{\arabic{mnotecnt}}}
\newcommand\mpar[1]{\refstepcounter{mnotecnt}\themnotecnt\marginpar{\footnotesize\themnotecnt\hspace{1pt}#1}}
\newcommand\mnote[1]{\refstepcounter{mnotecnt}\themnotecnt\marginnote{\footnotesize\themnotecnt\hspace{1pt}#1}}
\newtcbtheorem[]{mytheo}{Theorem}{}{thm}
\begin{document}
This is a sentence.\mpar{Margin note using the marginpar command.}
\blindtext
\begin{mytheo}{}{}
This is a theorem.\mnote{Margin note using the marginnote package.}
\end{mytheo}
\section*{Problems:}
\begin{mytheo}{}{}
This is a theorem.\mnote{marginnote} This is a sentence.\mnote{another one}
(should not overlap!)
\end{mytheo}
\begin{align*}
\alpha + \beta = \gamma%\mpar{Does not work.} % comment out for error
\end{align*}
\begin{mytheo}{}{}
This is a theorem.%\mpar{Does not work.} % comment out for error
\end{mytheo}
\end{document}
.tex
file and read using\input
. I really need to update the solution anyway. See also tex.stackexchange.com/questions/573329/…\input
didn't work for me earlier, but now it does, weird. Sadly, I don't know how to implement the solution displayed in the last link you provided. I also tried setting theonepage
option in both the report and article class but the margin notes still switch sides. Furthermore, using one of the packagesxifthen
orcalc
leads to the margin notes being moved down to the end of the page. Is there a fix to this? I would really appreciate an updated version if you have the time to make one!