1

I'm hoping that some wizard is willing to help me recreate a diagram for my dissertation in LaTeX (tikz?).

Series of overlapping boxes describing an experimental procedure.

The original has been generously created for me by my advisor. She has consented to my using it or recreating it in any way, as well as for my asking for help here to do so. I think she originally made it in power point. I am 100% happy with it except that it is obviously not easily scalable, and just looks a bit jaggy in my otherwise crisp document, since it is not vector graphics. I'd love to recreate it using LaTeX/tikz-pgf, but my skills with the software are not up to the challenge and I just don't have time right now to figure it out.

I realize this may be an entirely unreasonable request, and that I am entirely looking for charity. Feel free to let me know if this is entirely inappropriate.

  • 3
    Please show us, what you try so far! – Zarko Aug 26 at 20:23
  • Is none of the given answers to any help? Since you asked for charity, I think it is reasonably to give some feedback. – Sveinung Aug 28 at 12:08
  • 1
    I apologize, I've been preparing for my dissertation defense today! All three answers are great. I will be implementing one next week before I deposit, and when I do, I will come back and let everyone know what I decided on, I am very grateful for all the answers. I'll also acknowledge all three of the answer authors in document that no one will ever read o:) – Tyler Peckenpaugh Aug 29 at 13:55
  • 1
    Thank you for the feed back. Good luck with your defence. – Sveinung Aug 29 at 21:15
6

I think it is no useful to create such a simple tikz picture for you. Instead of creating one, I will show you a small example and try to explain it to you. Then you can create one by yourself.

Example:

Example picture

\documentclass[tikz, border=2pt]{standalone}

\usetikzlibrary{positioning}

\begin{document}
    \begin{tikzpicture}
        \node (text1) [draw, text width=5cm, minimum height=2\baselineskip, align=center, fill=white] at (0,0) {My text 1};
        \node (text2) [draw, text width=5cm, minimum height=2\baselineskip, align=center, fill=white] at (.5,-.7) {My text 2};

        \node[anchor=south west] at (text1.east) {Text next to box 1};
        \node[anchor=south west] at (text2.east) {Text next to box 2};
    \end{tikzpicture}
\end{document}

A node is text component of tikz. The syntax of it is the following: \node (nameOfTheNode) [style options] at (position) {LaTeX code}. The name and the style options are optional. In "LaTeX code" you can add nearly every command. In your cas it is a simple text.

Let's have a look on the options of the first \node.

  • The draw option creates a box around the node
  • The text width defines the width of the node. If you don't use this options, the width is fitted to the width of the content.
  • minimum height should be clear
  • \baselineskip is not a node option, but the textheight. It is not a tikz command. You can use it everywhere in your LaTeX document.

If you have questions to the other options, feel free to ask in the comments.

At last lets have a look on the last both nodes. The position of this nodes looks different. The position can also be a variable. The name of a node can always be used as position. If you type a dot after the name, you can call an anchor of a node. A anchor defines a specific position of an node. In this case, we want to use the coordinate of the horizontal right side (east).

With the options to this node, we tell it that the position we define is not the centre of the new node, but the position of the coordinate at the bottom and the left site of the node.

I hope you understand my explanation. If you have any questions feel free to ask in the comments section.

Edit:

If you want to rise the text next to the boxes, you can do that by choosing different anchors. I think you want to have the text next to the top right corner of the box. That means, that you choose the north east anchor from the box and you want to set the west anchor of the node next to the box.

\node[anchor=west] at (text.north east) {Text next to box};
  • 2
    +2 for good explanation -1 for sledgehammer (tikz)= +1. :) "Text next to box" is not raised. Maybe you should explain how? :) – Sveinung Aug 26 at 21:57
  • 2
    Thank you for drawing my attention to that. I didn't noticed, that the text is raised. I wrote an edit to fix that issue. – Ahrtaler Aug 27 at 7:23
  • 1
    you are wonderful, thank you! – Tyler Peckenpaugh Aug 29 at 13:56
6

You don't really need TikZ to recreate this diagram: ordinary tools such as xcolor and eqparbox will do:

\documentclass{article}
\usepackage{xcolor}
\usepackage{array}
\usepackage{eqparbox}
\usepackage{stmaryrd}
\newcommand{\myframebox}[2][Dia]{\setlength{\fboxsep}{2.5ex}\raisebox{\dimexpr-\height + 0.5ex}{\fcolorbox{black}{white}{\eqmakebox[#1]{\enspace #2\enspace}}}}

\begin{document}

\begin{tabular}{l}
\setlength{\fboxsep}{2.5ex}
 \myframebox{Sentence Display $\shortrightarrow$ \textbf{Reading 2}} \enspace DONE terminates \\[-3ex]
 \hskip 2em \myframebox{Inter-Reading Screen}\enspace START terminates \\[-3ex]
\hskip 4em\myframebox{Sentence Display $\shortrightarrow$ \textbf{Reading 1}}\enspace NEXT terminates \\[-3ex]
 \hskip 6em \myframebox{Fixation Screen}\enspace START terminates
 \end{tabular}

\end{document} 

enter image description here

  • Very nice answer! – Sveinung Aug 26 at 21:40
  • Thanks! Yours is fine too. I see we had the same basic ideas: using \fcolorboxes and stmaryrd. (+1 for not using a hammersledge). – Bernard Aug 26 at 21:45
  • As you see, I borrowed the stmaryrd from you (but with credit). – Sveinung Aug 26 at 21:54
  • I think your solution is realy nice, but I don't understand, why you use the tabular environment. May you explain that to me? – Ahrtaler Aug 27 at 7:28
  • 1
    @Ahrtaler: Sorry, I hadn't seen you comment until now. Actually, I first vertically aligned the words after the boxes and I used two columns for that, until I noted this was not required. So it's really no more necessary. – Bernard Aug 29 at 14:04
5

No tikzwizardly here, but a brute force attempt using \fcolorboxes and textpos. The macro \zz is crucial, because it gives the \parbox height. Without it, the figure overlaps surrounding text. A \texblock environment takes up zero space on the page (which means it does not detect it is overprinting or being overprinted).

I gave the \fcolorbox white background, which give the impression the boxes are stacked. You may use fancy colours, or just four shades of gray (not fifty). Remember to use darker colour on those boxes that overprint the previous to hide overprinted rules. See at the end of the answer how nice it looks in colour.

I defined four text positioning macros to fix the position of the boxes. You could define only one and use variables for coordinates.

The solution is not sophisticated, so handle with care!

enter image description here

enter image description here

\documentclass[fontsize=12pt]{scrartcl}
\usepackage{textpos}
\usepackage{stmaryrd}       % Thanks to @Bernard
\setlength{\fboxsep}{10pt}
\setlength{\TPHorizModule}{1mm}
\setlength{\TPVertModule}{1mm}
\usepackage{xcolor, lipsum}

\newcommand{\zz}{\vphantom{\rule{1mm}{37.5mm}}}

\DeclareRobustCommand*{\boxen}[1]{%     % Box one
  \begin{textblock}{150}(15,28.5)
      #1%
  \end{textblock}%
  }

\DeclareRobustCommand*{\boxto}[1]{%      % Box two
  \begin{textblock}{150}(10,19)
      #1%
  \end{textblock}%
  }

\DeclareRobustCommand*{\boxtre}[1]{%     % Box three
  \begin{textblock}{150}(5,9.5)
      #1%
  \end{textblock}%
  }

\DeclareRobustCommand*{\boxfire}[1]{%     % Box four
  \begin{textblock}{150}(0,0)
      #1%
  \end{textblock}%
  }

\begin{document}

\lipsum[1-7]\par
\begin{figure}
\parbox{200mm}{%
\boxfire{\fcolorbox{gray}{white}{\makebox[70mm]{Sentence display $\shortrightarrow$ \textbf{Reading 2}}}\hspace{10pt}\raisebox{10pt}{DONE terminates}}
\boxtre{\fcolorbox{gray}{white}{\makebox[70mm]{Inter-Reading Screen}}\hspace{10pt}\raisebox{10pt}{START terminates}}
\boxto{\fcolorbox{gray}{white}{\makebox[70mm]{Sentence display $\shortrightarrow$ \textbf{Reading 1}}}\hspace{10pt}\raisebox{10pt}{NEXT terminates}}
\boxen{\fcolorbox{gray}{white}{\makebox[70mm]{Fixation Screen}}\hspace{10pt}\raisebox{10pt}{START terminates}}%
\zz}
\caption{A describing figure\label{fig:figure1}}
\end{figure}

\end{document}
  • this looks great also, thanks so much! I am sure I will have questions once I am implementing – Tyler Peckenpaugh Aug 29 at 13:57

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.