Menu

#345 tikz overlay combined with baseline doesn't work as expected

v1.0 (example)
open
None
5
2019-03-18
2014-12-06
U_Fischer
No

When I use the baseline key in an overlay TikZ picture the picture suddenly has a nonzero depth:

\documentclass[]{article}
\usepackage{tikz}

\begin{document}
\begin{minipage}[t]{4cm}
abc\\
abc\tikz[overlay,opacity=0.5,red,baseline={(3,3)}]\filldraw (0,0)rectangle (3,3);def\\
abc
\end{minipage}
\end{document}

It looks like a bug to me. See also http://tex.stackexchange.com/questions/215583/tikz-overlay-combined-with-baseline

Ulrike Fischer

Discussion

  • Henri Menke

    Henri Menke - 2019-01-18

    What do you suggest baseline should do instead?

     
  • U_Fischer

    U_Fischer - 2019-01-18

    Well the expected output was this:

    \documentclass[]{article}
      \usepackage{tikz}
    
      \begin{document}
    
      \begin{minipage}[t]{4cm}
      abc\\
      abc\raisebox{0pt}[0pt][0pt]{\tikz[overlay,opacity=0.5,red,baseline={(3,3)}]\filldraw (0,0)rectangle (3,3);}def\\
      abc
      \end{minipage}
      \end{document}
    

    That means the reference point of the picture relative to the "outside" is at (3,3) and that the picture has a 0pt size.

     
    • Henri Menke

      Henri Menke - 2019-01-18

      I get that, but how do you suggest this is accomplished without breaking all existing uses of baseline? I'm very tempted to close this as wont-fix because there is a workaround for this and baseline is also semantically meaningless for an overlay.

       

      Last edit: Henri Menke 2019-01-18
  • U_Fischer

    U_Fischer - 2019-01-19

    I'm not sure what you mean by "semantically meaningless". Setting the baseline changes the reference point and so the placement on the line. That's quite independent from the question if the picture occupies space or not. I also don't think that it would break current usages of baseline. What I don't know is if the behaviour can be implemented without breaking something - percusse comments in the tex.sx sounded as if it could be difficult. In this case it should be documented that some keys can break overlay and that baseline is one of them.

     
  • Henri Menke

    Henri Menke - 2019-01-21
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,16 +1,16 @@
     When I use the baseline key in an overlay TikZ picture the picture suddenly has a nonzero depth:
    +~~~tex
    +\documentclass[]{article}
    +\usepackage{tikz}
    
    
    -     \documentclass[]{article}
    -      \usepackage{tikz}
    -
    -      \begin{document}
    -      \begin{minipage}[t]{4cm}
    -      abc\\
    -      abc\tikz[overlay,opacity=0.5,red,baseline={(3,3)}]\filldraw (0,0)rectangle (3,3);def\\
    -      abc
    -      \end{minipage}
    -      \end{document}
    -
    +\begin{document}
    +\begin{minipage}[t]{4cm}
    +abc\\
    +abc\tikz[overlay,opacity=0.5,red,baseline={(3,3)}]\filldraw (0,0)rectangle (3,3);def\\
    +abc
    +\end{minipage}
    +\end{document}
    +~~~
     It looks like a bug to me. See also http://tex.stackexchange.com/questions/215583/tikz-overlay-combined-with-baseline
    
     Ulrike Fischer
    
    • assigned_to: Henri Menke
     
  • Florent Rougon

    Florent Rougon - 2019-03-18

    Hi,

    I hope I'm not stating the obvious, but the unwanted depth appears to come from the fact that the tikzpicture produces \lower〈dimen〉〈box〉 in this case, instead of just a 〈box〉. The 〈box〉 has zero width, height and depth:

    \hbox(0.0+0.0)x0.0, shifted 85.35823
    

    but the fact that it is lowered (apparently due to the use of 'baseline') influences the depth[1] of the enclosing box (in this case, the line containing 'abc' and 'def'). This can be shown with

    \showboxbreadth=\maxdimen \showboxdepth=20
    %\tracingcommands=1 % uncomment to see the \lower command
    \tracingoutput=1\tracingonline=1
    

    HTH, thanks to both of you for all the great work!

    [1] Possibly the height too, depending on the context.

     
MongoDB Logo MongoDB