This question led to a new package:

I have a node positioned in a shaded rectangle with:

  \begin{tikzpicture}[remember picture,overlay]
      at (current page.north east) {
      \tikz\shade[shading=axis,bottom color=\tableftcolor,
                  top color=\tabrightcolor,shading angle=-90]
        (0,0) rectangle (\tabwidth,\tabheight)
           node[rotate=90,pos=\tabtextpos] {\tabstyle#1};

Typically, when \tabtextpos has value 0.5, the text is centered in the shape, both vertically and horizontally:

0.50, centered

Now if I used 0.38 to put it more to the left, I get:

0.38, not centered

which is more to the left, but also down.

How could I put it to the left while still keeping it centered vertically?


This code is now part of a module called fancytabs, available on CTAN.


The factor you give is between the given rectangle path coordinates (0,0) and (\tabwidth,\tabheight). This moves it diagonal. If you don't want that you need to place it either using a different path (which doesn't has to draw anything), i.e. between (0,.5*\tabheight) and (\tabwidth,.5*\tabheight) or better directly:

  \tikz\shade[shading=axis,bottom color=\tableftcolor,
                  top color=\tabrightcolor,shading angle=-90]
        (0,0) rectangle (\tabwidth,\tabheight)
           node [rotate=90] at (\tabtextpos*\tabwidth,.5*\tabheight) {\tabstyle#1};

Note that in this implementation \tabtextpos must be numeric, while before it could also be a string like 'midway', 'near end', etc.

You could also the calc tikzlibrary syntax: ($ (0,.5*\tabheight) ! \tabwidth ! (\tabwidth,.5*\tabheight) $), but for this usage this would be overkill.

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.