Tikz 环境中的段落间距

Tikz 环境中的段落间距

我希望在 tikz 环境(实际上是一个小页面)中复制段落的外观。

\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}  

我知道我可以使用“\vpsace”手动添加空格,但结果通常不太好看。

答案1

该问题与 无关,tikz但是 是一个问题minipage

在 中minipage,参数\parskip\parindent似乎被重置。
因此,您可以调整来自的解决方案如何在 minipage 中保留相同的 parskip定义一个minipageparskip保留\parskip和 的环境\parindent。以下是之前(红色)和之后的比较:

在此处输入图片描述

参考:

代码:

\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}

相关内容