I'm with a document that has margin notes in the section titles. I have programmed a command that works if I don't load titlesec
package. Here is a minimal example:
\documentclass[a4,twoside]{article}
\usepackage[spanish]{babel}
\usepackage{blindtext}
\usepackage{changepage}
\usepackage{marginnote}
\usepackage{calc}
% \usepackage{titlesec} % No titlesec crap, works
\setlength{\parindent}{0pt}
\newcommand{\margen}[2][0pt]{%
\marginnote{%
\normalfont\footnotesize
\checkoddpage
\ifoddpage {\parbox[t]{\marginparwidth}{\raggedright{\normalfont\footnotesize#2\normalfont}}}
\else {\parbox[t]{\marginparwidth}{\raggedleft{\normalfont\footnotesize#2\normalfont}}}
\fi
}[#1]
}
\newlength\altura
\setlength{\altura}{\heightof{{\Large C}}}
%\setlength{\altura}{\heightof{{C}}}
%\setlength{\altura}{0pt}
\begin{document}
\section[Uno]{One\marginnote{Test text}}
\blindtext[1]
\section[Dos]{Two \margen{Another secion note}}
\blindtext[1]
\section[Tres]{Three\margen{\blindtext}}%
\blindtext[2]
\section[Four]%
%{Four \margen[-\altura]{Fourth note \\and a little more text}} % One of the tests modifying the height.
% With the configuration of this file, it does not work.
{Four \margen{Fourth note \\and a little more text}}
\blindtext[1]
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%
The problem is that when I activate titlesec
, an extra vertical space appears, I don't know where it comes from. I've been testing with marginnote
's loading parameters, but it means having to insert vertical elements for the correct alignment. Another solution I was considering, is to force a vertical movement, but I can't find a convenient way to know the size of the extra space included in titlesec
.
I would be happy to receive any solution, suggestion or hint to solve this.
Best regards.
Edit:
This is the correct alignment form:
And this is the wrong way, when titlesec
is loaded:
\iffoddpage
in which case the code does not compile. What exactly is that off page suppose to do? There are way too many}
in that macroa4
option. It'sa4paper
.