9

In the following code, the marginnote is logically aligned to the lipsum text. I would like to align the marginnote to the title of the section.

What's the trick to use ?

% Source : http://tex.stackexchange.com/questions/36432/tiks-draw-in-left-margin-putting-old-calendar-style-date-in-margin

\documentclass[12pt]{article}
    \usepackage{lipsum}
    \usepackage{marginnote}
    \usepackage{tikz}
    \usetikzlibrary{calc}
    \usetikzlibrary{backgrounds}

    \newcommand*{\Date}[4]{%
        \begin{tikzpicture}[show background rectangle,inner frame sep=0pt,text width=1cm,align=center]
            \node [fill=orange] at (0,0)                                (dayofweek)  {#1};
            \node [fill=white ] at ($(dayofweek)  +(0,-\baselineskip)$) (dayofmonth) {#2};
            \node [fill=white ] at ($(dayofmonth) +(0,-\baselineskip)$) (month)      {#3};
            \node [fill=orange] at ($(month)      +(0,-\baselineskip)$) (dayofmonth) {#4};
        \end{tikzpicture}
    }

    \reversemarginpar % To put the margin pars on the left


\begin{document}

\section*{One day} \marginnote{\Date{Mon.}{28}{Nov}{2011}}
\noindent\lipsum[1]

\end{document}
14

Put the \marginnote inside the argument of \section* (and add \normalfont\normalsize).

\section*{One day\marginnote{\normalfont\normalsize\Date{Mon.}{28}{Nov}{2011}}}

EDIT: A better way is to change the definition of \marginfont to \normalfont\normalsize:

\documentclass[12pt]{article}

\usepackage{lipsum}

\usepackage{marginnote}
\reversemarginpar % To put the margin pars on the left
\renewcommand*{\marginfont}{\normalfont\normalsize}

\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}

\newcommand*{\Date}[4]{%
  \begin{tikzpicture}[show background rectangle,inner frame sep=0pt,text width=1cm,align=center]
    \node [fill=orange] at (0,0)                                (dayofweek)  {#1};
    \node [fill=white ] at ($(dayofweek)  +(0,-\baselineskip)$) (dayofmonth) {#2};
    \node [fill=white ] at ($(dayofmonth) +(0,-\baselineskip)$) (month)      {#3};
    \node [fill=orange] at ($(month)      +(0,-\baselineskip)$) (dayofmonth) {#4};
  \end{tikzpicture}
}

\begin{document}

\section*{One day\marginnote{\Date{Mon.}{28}{Nov}{2011}}} 

\noindent\lipsum[1]

\end{document}

enter image description here

Last, but not least, you may change the vertical positioning of the \marginnote using its second optimal argument:

\section*{One day} \marginnote{\Date{Mon.}{28}{Nov}{2011}}[-30pt]
|improve this answer|||||

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.