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.

Consider the simple time-line table shown in the image below (extracted from a book).

enter image description here

and the MWE below defining it as an environment,

\documentclass[twocolumn,10pt]{article}
\usepackage{mathpazo,calc,tikz}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{microtype}
\usepackage{array,booktabs,colortbl}
\color[gray]{.1}
\makeatletter
\newif\if@top
\@toptrue
\if@top \def\one{\leavevmode\par}\def\two{\vfill}\fi
\newif\if@center
\if@center\def\one{\vfill}\def\two{\vfill}\fi
\newif\if@bottom
\@bottomtrue
\if@bottom\def\one{\vfill}\def\two{}\fi


\makeatother
\newenvironment{timeline}[1][1534--40]{%
    \one
    \long\def\Row##1##2{\rowcolor{yellow!8}[5pt][2pt]\textbf{##1}&##2 \\ \midrule}%
    \setlength{\tabcolsep}{0pt}%
    \arrayrulecolor{yellow}%
    \renewcommand{\arraystretch}{1}%
    \sffamily
    \noindent
    \newlength\templength
    \settowidth{\templength}{#1}%
    \addtolength{\templength}{1em}%
        \begin{tabular}{p{\templength}p{\dimexpr\columnwidth-\templength-2pt}}%
             \hline
             \multicolumn{2}{>{\columncolor{yellow!25}[5pt][3pt]}l}{\bfseries KEY EVENTS}\\
             \hline}%
       {\end{tabular}%
       \two\vspace{-6.5pt}
}
\begin{document}
\lipsum[1-5]

\begin{timeline}
  \Row{1520}{Death of Raphael. His later works were considered the beginning of Mannerism}
  \Row{1528}{Sack of Rome. Spreads Mannerism across Italy and France}
  \Row{c.\thinspace1528}{Jacobo Pontomo finishes his \textit{Deposition}, a Florentine altarpiece in the Mannerist style}
  \Row{1534--40}{Girolano Parmigiano paints \textit{The\newline Madonna of the Long Neck}}
  \Row{1541}{Birth of El Grego}
\end{timeline}

\end{document}

Can you assist in getting it closer to the original? Two generic issues, the background color around the Key Events heading, blending as a frame around the rows, and the second one removing the additional space at the bottom to line it with the baseline of the left column text (manually corrected in the MWE). There are also other minor differences.

enter image description here

It is probably better to view the style in context from the book Art by Robert Cumming, published by DK Publications.

enter image description here

share|improve this question
    
Try saving the table using \lrbox, measure what's in the box, and put what's in the box on a coloured, filled rectangle that's slightly bigger. –  Marc van Dongen Sep 20 '13 at 11:54
    
It should be “Jacopo da Pontormo”, “Girolamo Parmigianino" and "El Greco” (Doménikos Theotokópoulos; maybe “El Griego”, but never ”El Grego”). The name "Il Greco” was used when he was in Italy and he carried it over when he went to Spain. –  egreg Sep 20 '13 at 14:56
    
About "Parmigiano", the source table is wrong: the "Madonna dal collo lungo" is Parmigianino's. See it.wikipedia.org/wiki/… –  egreg Sep 20 '13 at 15:07
    
@egreg There are a lot of errors in the original book (see image above). A must to check references, sources and facts. Thanks for picking it up. –  Yiannis Lazarides Sep 20 '13 at 15:15

3 Answers 3

up vote 4 down vote accepted

I tried to replicate the table but I don't have a narrower font other than Arial Narrow. I didn't construct the full environment but I thought it might be better to type in the contents directly into a table. So I used pgfplotstable but datatool would also do it fine. Hence, it's kind of a conceptual answer.

I've put the table in a tikz node and made the title an external node (What a surprise)

EDIT Now it works as a simple command \timeline{<Title>}{<tabular content>}

\documentclass[twocolumn]{article}
\usepackage{fontspec}
\setsansfont[Ligatures=TeX]{Arial Narrow}
% ================================================================================
\usepackage{pgfplotstable,booktabs,colortbl,microtype,xparse,kantlipsum}
\usetikzlibrary{matrix}
\pgfplotsset{compat=1.8}
% ================================================================================

 \NewDocumentCommand{\timeline}{m+m}{%
 \begin{tikzpicture}[baseline,font=\sffamily]
 \matrix[matrix of nodes,draw=yellow!40,ultra thick,inner sep=0pt,ampersand replacement=\&,nodes={anchor=center},row sep=-.5\pgflinewidth]{
 |[font=\sffamily\bfseries,align=left,fill=yellow!25,text width={7cm},inner ysep=1.2ex]| \hspace{0.75em}#1\\ % Title node
 |[inner xsep=0.5em,inner ysep=1.8ex,fill=yellow!8]|
    {\pgfplotstabletypeset[ % Table inside the second row node
    string type,
    every odd row/.style={after row={\midrule}},
    every even row/.style={after row={\midrule}},
    every last row/.style={after row={}},
    every head row/.style={output empty row},
    display columns/0/.style={column type={@{}p{9mm}},postproc cell content/.style={@cell content=\textbf{####1}}},
    display columns/1/.style={column type={p{5.3cm}@{}}},
    col sep=ampersand, row sep=\\, header=false,
    ]{#2}}\\   % End of node, \\ is needed
 };            % End of matrix node
 \end{tikzpicture}
 } 

\begin{document}\sffamily
\kant[1-2]

\timeline{KEY EVENTS}{
      1520             & Death of Raphael. His later works were\newline considered the beginning of Mannerism\\
      1527             & Sack of Rome. Spreads Mannerism\newline across Italy and France\\
      c.\thinspace1528 & Jacobo Pontomo finishes his \emph{Deposition}, a\newline Florentine altarpiece in the Mannerist style\\
      1534--40         & Girolano Parmigiano paints \emph{The\newline Madonna of the Long Neck}\\
      1541             & Birth of El Grego\\
}

\kant[3]

\timeline{BREAKING NEWS}{
      16:55             & Nero is looking hot today\\
      23:00             & Fire!! \\
      05:55             & Smoke on the Water....\newline Fire in the sky!\\
}    
\end{document}

enter image description here

share|improve this answer
    
Thanks for posting it as a TikZ solution. User interface is important, but I can turn it into an environment. Looks good. I am not too much worried about the font and arial narrow certainly is better for narrow tables. –  Yiannis Lazarides Sep 20 '13 at 14:33
    
@YiannisLazarides My pleasure. I think I forgot to simplify a few things and the rule colors. I'll try to look into it if time permits. –  percusse Sep 20 '13 at 14:41
    
@YiannisLazarides Made it slightly more useful. –  percusse Sep 20 '13 at 20:48

It's not pretty, but it may be what you are looking for. It's hard to see in yellow, but if you put your MWE in blue, the difficulties become much more apparent. The key differences from your approach are:

1) I used two tabulars, one for the header and one for the rest (this allowed me to avoid problems with multicolumn and color).

2) I wrapped everything in a \colorbox to avoid getting white space between the rows.

Along the way, I had to trim a box vertically with \addvbuffer and throw in a \strut.

\documentclass[twocolumn,10pt]{article}
\usepackage{mathpazo,calc,tikz}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{microtype}
\usepackage{array,booktabs,colortbl}
\usepackage{verbatimbox}
\color[gray]{.1}
\makeatletter
\newif\if@top
\@toptrue
\if@top \def\one{\leavevmode\par}\def\two{\vfill}\fi
\newif\if@center
\if@center\def\one{\vfill}\def\two{\vfill}\fi
\newif\if@bottom
\@bottomtrue
\if@bottom\def\one{\vfill}\def\two{}\fi

\makeatother
\newenvironment{timeline}[1][1534--40]{%
    \one%
    \long\def\Row##1##2{%\rowcolor{blue!8}[5pt][2pt]
      \textbf{##1}&##2 \\ \midrule}%
    \setlength{\tabcolsep}{0pt}%
    \arrayrulecolor{yellow!75}%
    \renewcommand{\arraystretch}{1}%
    \sffamily%
    \noindent%
    \newlength\templength%
    \settowidth{\templength}{#1}%
    \kern-2.5pt\addvbuffer[-3pt 1pt]{\colorbox{yellow!25}%
    {\begin{tabular}{@{\hspace{-.5pt}}p{\columnwidth}}%
      \bfseries KEY EVENTS%
    \end{tabular}}}\\%
    \addtolength{\templength}{1em}%
        \begin{tabular}{p{\templength}%
          p{\dimexpr\columnwidth-\templength%
           %-2pt%
           }}%
%             \hline%
%             \multicolumn{2}{>{\columncolor{yellow!25}%
%               [3pt][3pt]%
%               }l}{\bfseries KEY EVENTS}\\%
%             \hline%
       }%
       {\end{tabular}%
       \two\vspace{-6.5pt}%
}
\begin{document}
\lipsum[1-5]

\newsavebox{\mytab}
\sbox{\mytab}{\colorbox{yellow!8}{\vbox{%
\begin{timeline}
  \Row{1520}{Death of Raphael. His later works were considered the beginning of Mannerism}
  \Row{1528}{Sack of Rome. Spreads Mannerism across Italy and France}
  \Row{c.\thinspace1528}{Jacobo Pontomo finishes his \textit{Deposition}, a Florentine altarpiece in the Mannerist style}
  \Row{1534--40}{Girolano Parmigiano paints \textit{The\newline Madonna of the Long Neck}}
  \Row{1541}{Birth of El Grego}
\end{timeline}%
}}}
\vfill
\color{yellow!75}\fboxsep=-.25pt\relax\fbox{\usebox{\mytab}\strut}
\end{document}

enter image description here

share|improve this answer
    
Looks prettier in the original context (see my update for image). Thanks for posting your solution. –  Yiannis Lazarides Sep 20 '13 at 15:17

While my other solution tried to build upon the approach of your MWE, this solution is developed from scratch. Rather than using a tabular solution, I use here a stackengine solution, whereby I start stacking color \parboxes below the current stack, beginning with the header line. The stack is not output until the environment is closed. I believe the coding is significantly cleaner than the tabular approach.

The \Row macro now takes an optional argument, which if set to x, prevents the underrule from being set, which should be used for the final entry.

I also did this solution in blue, since I noted that it is easier to see than the yellow , on some monitors. Obviously, you would want to reset the blue values to yellow to get the scheme of your figure.

The final twist I added, in an effort to better match your font, was to vertically stretch the table by 15%. That can be removed, easily enough, if you either don't like it or if you find a different font to substitute.

\documentclass[twocolumn,10pt]{article}
\usepackage{mathpazo,calc,tikz}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{microtype}
\usepackage{array,booktabs,colortbl}
\usepackage{scalerel}
\usepackage[usestackEOL]{stackengine}[2013-09-11]
\color[gray]{.1}
\makeatletter
\newif\if@top
\@toptrue
\if@top \def\one{\leavevmode\par}\def\two{\vfill}\fi
\newif\if@center
\if@center\def\one{\vfill}\def\two{\vfill}\fi
\newif\if@bottom
\@bottomtrue
\if@bottom\def\one{\vfill}\def\two{}\fi

\makeatother

\newcommand\Row{}
\newlength\templength%
\def\stackalignment{l}%
\newenvironment{timeline}[1][1534--40]{%
  \one%
  \sffamily%
  \settowidth{\templength}{#1~~~}%
  \renewcommand\Row[3][l]{%
    \savestack{\anchorbox}{%
      \stackunder[0pt]{\anchorbox}{\colorbox{blue!8}{%
        \parbox{\columnwidth}{%
          \makebox[\templength][l]{\textbf{##2}}%
          \parbox[t]{\columnwidth-\templength}{\strut##3\strut}}}%
      }%
    }%
    \if x##1\else%
      \savestack{\anchorbox}{%
        \stackunder[-3pt]{\anchorbox}{\colorbox{blue!8}{%
          \color{black!75}\rule{\columnwidth}{.4pt}}%
        }%
      }%
    \fi%
  }%
  \savestack{\anchorbox}{\colorbox{blue!25}%
  {\parbox{\columnwidth}{\strut\bfseries KEY EVENTS}}}%
}%
{%
  \fboxsep=0pt\relax%
  \fboxrule=.4pt%
  \noindent\kern-3pt\color{blue!75}\fbox{\vstretch{1.15}{\anchorbox}}%
  \two%
}
\begin{document}
\lipsum[1-5]

\begin{timeline}
  \Row{1520}{Death of Raphael. His later works were considered the beginning of Mannerism}
  \Row{1528}{Sack of Rome. Spreads Mannerism across Italy and France}
  \Row{c.\thinspace1528}{Jacobo Pontomo finishes his \textit{Deposition}, a Florentine altarpiece in the Mannerist style}
  \Row{1534--40}{Girolano Parmigiano paints \textit{The\newline Madonna of the Long Neck}}
  \Row[x]{1541}{Birth of El Greco}
\end{timeline}%
\end{document}

enter image description here

share|improve this answer

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.