3

I'm working on the formatting of a text book.

The following picture shows the first thing I would like to do.

There are two things to achieve :

  1. I would like to "draw" the date using TikZ so as to have later the possibility to make more evoluated formatting.
  2. Then the "draw" must be put in the left margin.

enter image description here

The LaTeX code would be similar to the following one :

\section{Name of the class}

\subsection{Chapter A : Numeric activities}

\day{Mon.}{28}{Nov.}{2011}
\subsubsection{Lesson}
...

\subsubsection{For Tuesday Nov. 29}
...
2
  • 2
    Please don't ask "How do I achieve this layout", but rather a question about a specific feature that you're struggling with, one problem per question. This way other users who have a similar problem can benefit from your question and the solutions to it (No one's gonna ask for the same layout as you). It's no problem to ask several questions, if you've made some attempt yourself first. It's enormously helpful to see what you've tried so far to figure out what doesn't work. Is it putting something in the margin? Is it the table-layout with the colored cells? ...
    – doncherry
    Nov 28 '11 at 21:40
  • You're right. I've edited my question.
    – projetmbc
    Nov 28 '11 at 21:59
8

Here is a tikz solution using the marginnote package:

enter image description here

\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=1.5cm,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}
\marginnote{\Date{Mon.}{28}{Nov}{2011}}
\noindent\lipsum[1]
\end{document}
2
  • How can I center the text ?
    – projetmbc
    Nov 28 '11 at 22:14
  • Had already updated solution before you asked: use align=center. Nov 28 '11 at 22:15
4

You can use a simple tabular environment to format the date, and then frame it using a \fbox; the marginnote command (from the homonymous package) lets you place the date as a marginal note. In the following example I illustrate this approach; the \MyDate command has one mandatory argument (the name of the day); the other three values are typeset automatically (of course, you can make all or some of this elements also customizable as arguments of the command):

\documentclass{book}
\usepackage[table]{xcolor}
\usepackage{marginnote}
\usepackage{datetime}
\usepackage{lipsum}

\definecolor{mycolor}{RGB}{255,213,171}

\newcommand\MyDate[1]{%
  \marginnote{\setlength\fboxsep{0pt}%
  \fbox{\setlength\extrarowheight{3pt}%
    \begin{tabular}{>{\bfseries}c}
    \rowcolor{mycolor} #1 \\
    \large\the\day \\
    \large\shortmonthname. \\
    \rowcolor{mycolor} \the\year
    \end{tabular}%
  }}%
}

\reversemarginpar
\begin{document}

\MyDate{Mon.}\lipsum[1]

\end{document}

enter image description here

0

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.