14

I'm trying to make a diagram using Tikz, however I have trouble combining; fixed text widths, centered text and font=[\large,\bf , etc].

When the font command is used the text has a slight offset to the right.

the only idea I had, font=\noindent has no effect. MWE:

\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usetikzlibrary{shapes,shadows,arrows,positioning,graphs}

\begin{document}
\centering
\begin{tikzpicture}
\thispagestyle{empty}
\tikzstyle{fontbf} = [draw,rectangle,text width=11em,text centered,font=\bf]
\tikzstyle{textbf} = [draw,rectangle,text width=11em,text centered]
\node[fontbf] (1) {centered bold text};
\node[textbf, below of=1] (2) {\textbf{centered bold text}};
\end{tikzpicture}
\end{document}
16

The problem is that you are using font specific units to set the text width (em) and these units are different for bold and non-bold text. Use cm instead and the problem will disappear.

\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usetikzlibrary{shapes,shadows,arrows,positioning,graphs}
\begin{document}
  \centering
  \begin{tikzpicture}
    \thispagestyle{empty}
    \tikzstyle{fontbf} = [draw,rectangle,text width=5cm,text centered,font=\bfseries]
    \tikzstyle{textbf} = [draw,rectangle,text width=5cm,text centered]
    \node[fontbf] (1) {centered bold text};
    \node[textbf, below of=1] (2) {\textbf{centered bold text}};
  \end{tikzpicture}
\end{document}

enter image description here

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.