我使用创建了一个盒子
\tikzstyle{PBox}=[rectangle, rounded corners, fill=kopfzeile!10,
anchor=north, text=black, text width=\marginparwidth-2mm]
\put(-56,-150){\makebox(0,0)[bl]{\begin{tikzpicture}%
\node[PBox]{\small%
\singlespacing%
Wichtiger Hinweis!\\};
\end{tikzpicture}}}
每个 PBox 的开头总是有一个空行。如何避免这种情况?
答案1
您可以用另一种方式设置单倍行距以避免出现空行,\setstretch{1}
而是使用\singlespace
:
\documentclass{article}
\usepackage[doublespacing]{setspace}
\usepackage{tikz}
\tikzstyle{PBox}=[rectangle, rounded corners, fill=kopfzeile!10,
anchor=north, text=black, text width=\marginparwidth-2mm]
\begin{document}
\begin{picture}(20,20)
\put(-56,-150){\makebox(0,0)[bl]{\begin{tikzpicture}%
\node[PBox]{\small%
\setstretch{1}%
Wichtiger Hinweis!\\};
\end{tikzpicture}}}
\end{picture}
\end{document}
原因是,这\singlespacing
会垂直跳过一行,正如您在定义中所见:
\newcommand{\singlespacing}{%
\setstretch {\setspace@singlespace}% normally 1
\vskip \baselineskip % Correction for coming into singlespace
}
输出:
答案2
首先,最好发布一个完整的可编译的 MWE。其次,你需要使用figure
环境,并且需要将其放置\singlespacing
在节点之外
\documentclass[11pt]{article}
\usepackage{xcolor,tikz}
\usepackage{setspace}
\begin{document}
\tikzstyle{PBox}=[rectangle, rounded corners, fill=blue!10,
anchor=north, text=black, text width=\marginparwidth-2mm]
\singlespacing
\setlength\unitlength{1mm}
\begin{picture}(0,0)
\put(-51,-150){\makebox(0,0)[bl]{%
\begin{tikzpicture}
\node[PBox] {\small Wichtiger Hinweis!\\};
\end{tikzpicture}
}%
}%
\end{picture}
\end{document}