16

I was browsing the tikz examples that I found this wonderful example. The example uses tikz to create a tex environment to produce a framed text. The result looks like this:

TikZ framed text example

The underlying process may look too complicated for someone unfamiliar with tikz, but it is quite simple to use the environment:

\begin{parchment}[Paragraph Title]
    The main text goes here ...
\end{parchment}

Then, it came to my mind that it would be great to have some high level tex macros or environments to produce such fancy figures or plots. Something like SmartArt graphics in microsoft office. For instance, use something like this:

\begin{env-name}[Discipline]
    \usecolorpallet{pallet-name}
    \item Love
    \item Trust
    \item Self-control
    \item Journey
    \item Obedience
\end{env-name}

to produce figures like this or this. I think, these kind of high level environments, in addition to hiding the details of tikz, provides some novel ideas for making much more elegant slides and documents with tex.

So my question is: Is there any tex package that has such a functionality? If not, do you know any idea/example like the ones that I described, with available source code?

4
  • 1
    You can look at the mdframed package which has been an active topic of this site too. Here is a list of questions. I am not sure about the extras and flexibility though, however it's definitely possible once we put enough effort as the linked torn paper example. The latter two figures are more suitable with a TikZ macro.
    – percusse
    Apr 18, 2012 at 12:18
  • Should this really have the beamer label?
    – rvf0068
    Apr 18, 2012 at 22:54
  • Well, I'm not sure about it. I put the beamer label since the question is closely related to presentation slides.
    – Helium
    Apr 18, 2012 at 23:07
  • 2
    See package 'smartdiagram' (ctan.org/pkg/smartdiagram) Jan 17, 2014 at 5:48

4 Answers 4

19

Not exactly what you want ( high level environments) but I propose a macro. I made this macro very quicly, so it's possible to make something better. We can add styles etc.

\documentclass[11pt]{scrartcl}
\usepackage[utf8]{inputenc}  
\usepackage{tikz}

\makeatletter 
\@namedef{color@1}{red!40}
\@namedef{color@2}{green!40}   
\@namedef{color@3}{blue!40} 
\@namedef{color@4}{cyan!40}  
\@namedef{color@5}{magenta!40} 
\@namedef{color@6}{yellow!40}    

\newcommand{\graphitemize}[2]{%
\begin{tikzpicture}[every node/.style={align=center}]  
  \node[minimum size=5cm,circle,fill=gray!40,font=\Large,outer sep=1cm,inner sep=.5cm](ce){#1};  
\foreach \gritem [count=\xi] in {#2}
{\global\let\maxgritem\xi}  
\foreach \gritem [count=\xi] in {#2}
{% 
\pgfmathtruncatemacro{\angle}{360/\maxgritem*\xi}
\edef\col{\@nameuse{color@\xi}}
\node[circle,
     ultra thick,
     draw=white,
     fill opacity=.5,
     fill=\col,        
     minimum size=3cm] at (ce.\angle) {\gritem };}%
\end{tikzpicture}  
}%

\begin{document}

\graphitemize{Discipline}{Love,Trust,Self-\\control,Journey,Obedience}

\graphitemize{Mathématiques}{Algèbre,Géométrie,Analyse}
\end{document} 

enter image description here

Update

I added a new style, now it's possible to create some keys to chooose the style

\documentclass[11pt]{scrartcl}
\usepackage[utf8]{inputenc}  
\usepackage{tikz}
\usetikzlibrary{calc} 
\makeatletter 
\@namedef{color@1}{red!40}
\@namedef{color@2}{green!40}   
\@namedef{color@3}{blue!40} 
\@namedef{color@4}{cyan!40}  
\@namedef{color@5}{magenta!40} 
\@namedef{color@6}{yellow!40}    

\newcommand{\graphitemize}[2]{%
\begin{tikzpicture}[every node/.style={align=center}]  
  \node[minimum size=4cm,circle,fill=gray!40,font=\Large,outer sep =.25cm,inner sep=.5cm](ce){#1};  
\foreach \gritem [count=\xi] in {#2}  {\global\let\maxgritem\xi}  

\foreach \gritem [count=\xi] in {#2}
{% 
\pgfmathtruncatemacro{\angle}{360/\maxgritem*\xi}
\edef\col{\@nameuse{color@\xi}}
\node[circle,
     ultra thick,
     draw=white,
     fill opacity=.5,
     fill=\col,outer sep=0.25cm,        
     minimum size=2cm] (satellite-\xi) at (\angle:5cm) {\gritem };
     \draw[line width=0.5cm,->,\col] (ce) -- (satellite-\xi);
     }%
\end{tikzpicture}  
}%

\begin{document}

\graphitemize{Discipline}{Love,Trust,Self-\\control,Journey,Obedience}

\graphitemize{Mathématiques}{Algèbre,Géométrie,Analyse}
\end{document} 

enter image description here

2
  • Is it possible at all to use \items to separate the arguments to the environment, as the OP suggested in the question?
    – rvf0068
    Apr 25, 2012 at 0:44
  • @rvf0068 It's a complex (for me) TeX's problem. It's not like a list because when you add (graph) item, you modify the final result. Really I don't know ... What you need it's to give arguments; with a macro it's easy but to do something like a list seems to be very complicated. Apr 25, 2012 at 7:26
11

I have a written a timeline environment inspired by the question and answers of the following TeX.SX question: timeline and tikz

timeline

\documentclass[10pt]{article}

\usepackage[paperwidth=210mm,%
    paperheight=297mm,%
    tmargin=7.5mm,%
    rmargin=7.5mm,%
    bmargin=7.5mm,%
    lmargin=7.5mm,
    vscale=1,%
    hscale=1]{geometry}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tikz}

\usetikzlibrary{arrows, calc, decorations.markings, positioning}

\pagestyle{empty}

\makeatletter
\newenvironment{timeline}[6]{%
    % #1 is startyear
    % #2 is tlendyear
    % #3 is yearcolumnwidth
    % #4 is rulecolumnwidth
    % #5 is entrycolumnwidth
    % #6 is timelineheight

    \newcommand{\startyear}{#1}
    \newcommand{\tlendyear}{#2}

    \newcommand{\yearcolumnwidth}{#3}
    \newcommand{\rulecolumnwidth}{#4}
    \newcommand{\entrycolumnwidth}{#5}
    \newcommand{\timelineheight}{#6}

    \newcommand{\templength}{}

    \newcommand{\entrycounter}{0}

    % https://tex.stackexchange.com/questions/85528/checking-whether-or-not-a-node-has-been-previously-defined
    % https://tex.stackexchange.com/questions/37709/how-can-i-know-if-a-node-is-already-defined
    \long\def\ifnodedefined##1##2##3{%
        \@ifundefined{pgf@sh@ns@##1}{##3}{##2}%
    }

    \newcommand{\ifnodeundefined}[2]{%
        \ifnodedefined{##1}{}{##2}
    }

    \newcommand{\drawtimeline}{%
        \draw[timelinerule] (\yearcolumnwidth+5pt, 0pt) -- (\yearcolumnwidth+5pt, -\timelineheight);
        \draw (\yearcolumnwidth+0pt, -10pt) -- (\yearcolumnwidth+10pt, -10pt);
        \draw (\yearcolumnwidth+0pt, -\timelineheight+15pt) -- (\yearcolumnwidth+10pt, -\timelineheight+15pt);

        \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\startyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
        \node[year] (year-\startyear) at (\yearcolumnwidth, \templength) {\startyear};

        \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\tlendyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
        \node[year] (year-\tlendyear) at (\yearcolumnwidth, \templength) {\tlendyear};
    }

    \newcommand{\entry}[2]{%
        % #1 is the year
        % #2 is the entry text

        \pgfmathtruncatemacro{\lastentrycount}{\entrycounter}
        \pgfmathtruncatemacro{\entrycounter}{\entrycounter + 1}

        \ifdim \lastentrycount pt > 0 pt%
            \node[entry] (entry-\entrycounter) [below of=entry-\lastentrycount] {##2};
        \else%
            \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\startyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
            \node[entry] (entry-\entrycounter) at (\yearcolumnwidth+\rulecolumnwidth+10pt, \templength) {##2};
        \fi

        \ifnodeundefined{year-##1}{%
            \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(##1, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
            \draw (\yearcolumnwidth+2.5pt, \templength) -- (\yearcolumnwidth+7.5pt, \templength);
            \node[year] (year-##1) at (\yearcolumnwidth, \templength) {##1};
        }

        \draw ($(year-##1.east)+(2.5pt, 0pt)$) -- ($(year-##1.east)+(7.5pt, 0pt)$) -- ($(entry-\entrycounter.west)-(5pt,0)$) -- (entry-\entrycounter.west);
    }

    \newcommand{\plainentry}[2]{% plainentry won't print date in the timeline
        % #1 is the year
        % #2 is the entry text

        \pgfmathtruncatemacro{\lastentrycount}{\entrycounter}
        \pgfmathtruncatemacro{\entrycounter}{\entrycounter + 1}

        \ifdim \lastentrycount pt > 0 pt%
            \node[entry] (entry-\entrycounter) [below of=entry-\lastentrycount] {##2};
        \else%
            \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\startyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
            \node[entry] (entry-\entrycounter) at (\yearcolumnwidth+\rulecolumnwidth+10pt, \templength) {##2};
        \fi

        \ifnodeundefined{invisible-year-##1}{%
            \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(##1, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
            \draw (\yearcolumnwidth+2.5pt, \templength) -- (\yearcolumnwidth+7.5pt, \templength);
            \node[year] (invisible-year-##1) at (\yearcolumnwidth, \templength) {};
        }

        \draw ($(invisible-year-##1.east)+(2.5pt, 0pt)$) -- ($(invisible-year-##1.east)+(7.5pt, 0pt)$) -- ($(entry-\entrycounter.west)-(5pt,0)$) -- (entry-\entrycounter.west);
    }

    \begin{tikzpicture}
        \tikzstyle{entry} = [%
            align=left,%
            text width=\entrycolumnwidth,%
            node distance=10mm,%
            anchor=west]
        \tikzstyle{year} = [anchor=east]
        \tikzstyle{timelinerule} = [%
            draw,%
            decoration={markings, mark=at position 1 with {\arrow[scale=1.5]{latex'}}},%
            postaction={decorate},%
            shorten >=0.4pt]

        \drawtimeline
}
{
    \end{tikzpicture}
    \let\startyear\@undefined
    \let\tlendyear\@undefined
    \let\yearcolumnwidth\@undefined
    \let\rulecolumnwidth\@undefined
    \let\entrycolumnwidth\@undefined
    \let\timelineheight\@undefined
    \let\entrycounter\@undefined
    \let\ifnodedefined\@undefined
    \let\ifnodeundefined\@undefined
    \let\drawtimeline\@undefined
    \let\entry\@undefined
}
\makeatother


\begin{document}

\begin{timeline}{1900}{1990}{2cm}{2.5cm}{5cm}{12cm}
\entry{1903}{Wilbur and Orville Wright fly the first powered airplane}
\entry{1914}{Assassination of Franz Ferdinand}
\plainentry{1917}{The October Revolution}
\entry{1928}{Discovery of Penicillin}
\plainentry{1929}{Stock Market Crash of 1929}
\entry{1941}{Attack on Pearl Harbor}
\plainentry{1944}{D-Day}
\entry{1945}{The Bombing of Hiroshima}
\plainentry{1947}{Creation of Israel as a Jewish State}
\entry{1963}{US president John F. Kennedy assassinated in Dallas}
\entry{1969}{The Moon Landing}
\plainentry{1989}{Fall of the Berlin Wall}
\end{timeline}

\bigskip

Text from: A Brief History of LaTeX http://www.xent.com/FoRK-archive/feb98/0307.html

\smallskip

\begin{timeline}{1974}{1985}{2cm}{7cm}{10cm}{0.45\textheight}
\entry{1974}{Donald Knuth stops submitting papers to the AMS because ``the finished
product was just too painful for me to look at''.}
\entry{1977}{Knuth begins his research on typography.}
\entry{1978}{Knuth delivers an AMS Gibbs Lecture entitled Mathematical Typography to the AMS membership at its annual meeting.}
\entry{1979}{Digital Equipment Corporation and the AMS jointly publish Knuth's TeX and METAFONT: New Directions in Typesetting.}
\entry{1980}{The first draft of Spivak's Joy of TeX is announced in TUGboat, vol. 1, no. 1.}
\entry{1982}{Spivak announces AMS-TeX at the joint math meetings.}
\entry{1982}{Version 0 of Spivak's Joy of TeX is released.}
\entry{1982}{Knuth releases dvitype, a model DVI driver.}
\entry{1983}{Lamport writes a LaTeX manual, the earliest known LaTeX manual in existence.}
\entry{1984}{Addison-Wesley publishes Knuth's The TeXbook, destined to become the definitive TeX reference.}
\entry{1984}{Lamport releases version 2.06a of the LaTeX macros.}
\entry{1985}{The Computer Modern (CM) fonts replace the American Modern (AM) fonts in TeX.}
\entry{1985}{Patashnik releases BibTeX version 0.98 for LaTeX 2.08. [``BibTeX 1.0'', TUGboat, vol. 15, no. 3, pp. 269--274, Sept. 1994.}
\end{timeline}

\end{document}
3
  • 2
    Is there a way to have this span multiple pages?
    – Max N
    Nov 27, 2017 at 0:11
  • 1
    Can I put a different category of events on the left side of the years to juxtapose developments in two different fields?
    – Max N
    Nov 27, 2017 at 0:12
  • 1
    I'd like to be able to adapt this so that I can use events that happen in month resolution. In above example that the three events that happen in 1982 are more transparent on what comes before the other.
    – Max N
    Dec 3, 2017 at 16:29
6

Here is another one (I just adapted the code from Altermundus's answer):

enter image description here

\documentclass[11pt]{scrartcl}
\usepackage[utf8]{inputenc}  
\usepackage{tikz}
\usetikzlibrary{calc,shadows,arrows} 
\makeatletter 
\@namedef{color@1}{red!50}
\@namedef{color@2}{green!50}   
\@namedef{color@3}{blue!50} 
\@namedef{color@4}{cyan!50}  
\@namedef{color@5}{magenta!50} 
\@namedef{color@6}{yellow!50}    

\newcommand{\graphitemize}[1]{%
\begin{tikzpicture}[every node/.style={align=center}]  

\foreach \gritem [count=\xi] in {#1}  {\global\let\maxgritem\xi}  

\foreach \gritem [count=\xi] in {#1}
{% 
\pgfmathtruncatemacro{\angle}{90+360/\maxgritem*\xi}
\edef\col{\@nameuse{color@\xi}}
\node[circle,
     inner sep=7pt,
     outer sep=7pt,
     ultra thick,
     text opacity=1,
     fill opacity=.5,
     bottom color=\col,
     top color=white!70!\col,
     minimum size=3cm] (satellite\xi) at (\angle:4cm) {\gritem };
}%

\foreach \gritem [count=\xi] in {#1}
{% 
\pgfmathtruncatemacro{\xj}{mod(\xi, \maxgritem) + 1}
\edef\col{\@nameuse{color@\xi}}
\draw[arrows={->},line cap=rounded,line width=.5cm,\col\relax!0.5] (satellite\xj) to (satellite\xi);
}%
\end{tikzpicture}  
}%

\begin{document}

\graphitemize{Phase 1,Phase 2, Phase 3, Phase 4, Phase 5}

\end{document} 
4

Just to elaborate on my own comment: I think using the smartdiagram package will do almost exactly what you are asking for:

\documentclass{article}
\usepackage{smartdiagram}

\begin{document}

\centering

\smartdiagram[circular diagram]
    {Love,Trust,Self-control,Journey,Obedience}
\newpage

\smartdiagram[circular diagram:clockwise]
    {Love,Trust,Self-control,Journey,Obedience}
\newpage

\smartdiagram[flow diagram]
    {Love,Trust,Self-control,Journey,Obedience}
\newpage

\smartdiagram[flow diagram:horizontal]
    {Love,Trust,Self-control,Journey,Obedience}
\newpage

\smartdiagram[descriptive diagram]
    {Love,Trust,Self-control,Journey,Obedience}
\newpage

\smartdiagram[priority descriptive diagram]
    {Love,Trust,Self-control,Journey,Obedience}
\newpage

\smartdiagram[bubble diagram]
    {Love,Trust,Self-control,Journey,Obedience}
\newpage

\smartdiagram[constellation diagram]
    {Love,Trust,Self-control,Journey,Obedience}
\newpage

\smartdiagram[connected constellation diagram]
    {Love,Trust,Self-control,Journey,Obedience}
\newpage

\smartdiagram[sequence diagram]
    {Love,Trust,Self-control,Journey,Obedience}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .