Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I created a box using

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

I always get a blank line at the start of each PBox. How can I avoid this?

share|improve this question
8  
Can you please post complete, minimal code and not just snippets? –  Gonzalo Medina Nov 29 '11 at 23:15
    
I belive it is the \singlespacing that is doing adding the blank line. Once you post a complete compilable MWE we can investigate further. –  Peter Grill Nov 30 '11 at 0:27
add comment

2 Answers

up vote 5 down vote accepted

You could set the single spacing in another way to avoid the blank line, use \setstretch{1} instead of \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}

The reason is, that \singlespacing makes a vertical skip of one line, as you can see in the definition:

\newcommand{\singlespacing}{%
  \setstretch {\setspace@singlespace}%  normally 1
  \vskip \baselineskip  % Correction for coming into singlespace
}

Output:

single spaced box

share|improve this answer
add comment

First, It's preferable to post a complete compilable MWE. Secondly, you need to use an figure environment and you need to place \singlespacingoutsside the node

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

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.