5

How can I remove ALL space around TiKZ. So given MWE below, I want no space between fbox and the node box (so essentially I want to see 1 line). How to realize this?

Is this space in tikzpicture or in \fbox?

How to remove space between \fbox and node

enter image description here

MWE

\documentclass{article}
\usepackage{tikz} 
\begin{document}
\fbox{%
  \begin{tikzpicture}[node distance = 0.8cm and 0.2cm]%
    \node[draw] (center) {CENTER}; %
  \end{tikzpicture}%
}
\end{document}
  • 3
    \setlength{\fboxsep}{0pt}? But why are using \fbox when you can use TikZ already? – user31729 Jan 25 '17 at 13:01
  • I am using it for 'debug' purpose. So I want to place multiple figures side-by-side in 1 column. – robert Jan 25 '17 at 13:26
  • @robert, is any of received answer solve your problem? if it, please accept (by clicking on check mark at top left side of answer) then this one, which do this on way you most liked! – Zarko Mar 28 '17 at 18:10
7

The space is controlled equally to each of the four margins of the \fbox with \fboxsep, so the space is caused by \fbox. Setting it to 0pt will remove the space at all.

Use \setlength{\fboxsep}{0pt} inside a TeX group, i.e. {...} wrapping around will prevent that \fboxsep is changed globally.

Specifying \node[draw] has almost the same effect as using the outer \fbox.

\documentclass{article}
\usepackage{tikz} 
\begin{document}
{%
\setlength{\fboxsep}{0pt}
\fbox{%
  \begin{tikzpicture}[node distance = 0.8cm and 0.2cm]%
    \node[draw] (center) {CENTER}; %
  \end{tikzpicture}%
}
}

\fbox{%
  \begin{tikzpicture}[node distance = 0.8cm and 0.2cm]%
    \node[draw] (center) {CENTER}; %
  \end{tikzpicture}%
}


\begin{tikzpicture}[node distance = 0.8cm and 0.2cm]%
  \node[draw,line width=1.5\fboxrule] (center) {CENTER}; %
\end{tikzpicture}%

\end{document}

enter image description here

| improve this answer | |
4

You can use \frame instead of \fbox:

\documentclass{article}
\usepackage{tikz} 
\begin{document}
\frame{%
  \begin{tikzpicture}[node distance = 0.8cm and 0.2cm]%
    \node[draw] (center) {CENTER}; %
  \end{tikzpicture}%
}
\end{document}

\frame instead of \fbox

| improve this answer | |
  • I always forget that there's a built-in command \frame ... (+1) – user31729 Jan 25 '17 at 13:39

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.