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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
Perfect, thank you! – ℝaphink Apr 15 '11 at 21:43

Your Answer


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.