4

I am looking to replicate the look of paragraphs within a tikz environment (actually a minipage).

\documentclass[letterpaper,12pt]{book}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes,backgrounds,arrows}   
\usepackage{tabularx}
\tikzset{mybox/.style= {draw=black,fill=black!5,thick,rectangle,rounded corners,inner xsep=40pt, inner ysep=14pt}}
\begin{document}
\begin{tikzpicture}[transform shape]
\node [mybox] (box) { \begin{minipage}[t!]{0.75\textwidth}
{Then we look for \textbf{clues}. 

Okay, this is a good time to find any direction words. Those are words that tell you how the two blanks are related.

Here's one: ``while.'' The word ``while'' sets up a contrast between the first and second blanks. We know from Step One that both are people who work with stars, and now we also know that they are different kinds of people.     
}
\end{minipage} };
\end{tikzpicture}
\end{document}  

I know I can manually add space with '\vpsace' for instance, but the result is often not pretty.

6

This issue is not related to tikz but is an issue with minipage.

In a minipage, the parameters \parskip and \parindent seem to be reset.
So you can adapt the solution from How to preserve the same parskip in minipage to define a minipageparskip environment which preserves the \parskip and \parindent. Here is a before (in red) and after comparison:

enter image description here

References:

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes,backgrounds,arrows}   
\usepackage{tabularx}
\tikzset{mybox/.style= {draw=black,fill=black!5,thick,rectangle,rounded corners,inner xsep=40pt, inner ysep=14pt}}


\newlength{\currentparskip}
\newlength{\currentparindent}
\newenvironment{minipageparskip}[2][]
  {\setlength{\currentparskip}{\parskip}% save the value
    \setlength{\currentparindent}{\parindent}%
   \begin{minipage}[#1]{#2}% open the minipage
   \setlength{\parskip}{\currentparskip}% restore the value
   \setlength{\parindent}{\currentparindent}% restore the value
  }
  {\end{minipage}}

\begin{document}
\begin{tikzpicture}[transform shape]
\node [mybox,fill=red, fill opacity=0.2, text opacity=1] (box) { \begin{minipage}[t!]{0.75\textwidth}
Then we look for \textbf{clues}. 

Okay, this is a good time to find any direction words. Those are words that tell you how the two blanks are related.

Here's one: ``while.'' The word ``while'' sets up a contrast between the first and second blanks. We know from Step One that both are people who work with stars, and now we also know that they are different kinds of people.     
\end{minipage} };
\end{tikzpicture}

\begin{tikzpicture}[transform shape]
\node [mybox] (box) { \begin{minipageparskip}[t!]{0.75\textwidth}
Then we look for \textbf{clues}. 

Okay, this is a good time to find any direction words. Those are words that tell you how the two blanks are related.

Here's one: ``while.'' The word ``while'' sets up a contrast between the first and second blanks. We know from Step One that both are people who work with stars, and now we also know that they are different kinds of people.     
\end{minipageparskip} };
\end{tikzpicture}
\end{document}
| improve this answer | |
  • Thank you for the solution. I will be using this for sure. As a side note, would there be any reason why I shouldn't use \smallskip to get a little extra vertical space? I don't remember, but I seemed to have read at some point that the \_skip commands should be avoided. Is this this true? Within this context of course. – Calhistorian Apr 25 '13 at 17:54
  • 1
    @Calhistorian: You can use \smallskip if you want to have different spacing between individual paragraphs. But if you want all the paragraphs to have that spacing in this special environment you can simply use \setlength{\parskip}{\smallskipamount}. – Peter Grill Apr 25 '13 at 21:25
  • @Calhistorian: However, before you go and start changing the value of \parskip everywhere you should review Too much whitespace before lists when changing the \parskip length as changing \parindent and \parskip is considered as one of the "deadly sins" in l2tabu and should be avoided. – Peter Grill Apr 25 '13 at 21:28

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.