Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

1 Answer

up vote 12 down vote accepted

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]
share|improve this answer
    
That's great ! Thanks. –  projetmbc Nov 29 '11 at 18:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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