3

Take for example my code from https://tex.stackexchange.com/a/497174/191567

\documentclass{article}

\usepackage{tikz}

\begin{document}
    \tikzset{
        bloc/.style={
            anchor=south west, 
            draw, 
            minimum height=0.7cm, 
            align=left,
            font=\small
        },
    }



\begin{tikzpicture}
\pgfdeclarehorizontalshading{myshadingA}{3cm}{
    color(0cm)=(green); 
    color(1.44cm)=(green); 
    color(1.8cm)=(red)
}
\node[bloc, minimum width=5.5cm, 
      shading=myshadingA]  
at (-9,0.5) {Initialize process};

\end{tikzpicture}
\end{document}

I found out to place the end of the pgfshading at about 1.8cm by trial and error. Naively I would would have assumed it to end at 5.5cm, the width of the node. Why the different location?

EDIT:

Changing the vertical size from 3cm to something else does not seem to affect the dimension required in horizontal direction

Pizzagne
  • 188
  • I think you might be interested in this post, where it is explained why this happens, and what you can do about it. –  Jun 24 '19 at 15:35
  • @marmot Thanks for pointing out this link. As I understand it, it says the shading is scaled to only show the inner 50% ? Why do I need 1.8cm and not 5.5cm/2=2.75cm? – Pizzagne Jun 24 '19 at 21:43
  • The main reason why I was linking to this post is that it allows you to avoid having to guess. You do not need 2.75cm because there are two dimensions here: the ones you are mentioning and the 3cm in \pgfdeclarehorizontalshading{myshadingA}{3cm}{.... –  Jun 24 '19 at 22:14
  • @marmot Thanks for your reply. The other dimension does not have any effect on the 1.8cm, I already tried that. I don't really want to avoid having to guess, I just would like to know know why the values are not the same – Pizzagne Jun 24 '19 at 22:25

0 Answers0