5

I would like illustrate a deliberately overfull progressbar. I am using \progressbar and tikz, but the relative positioning (east) is always off by a bit in the X direction and I don't know why. Consider the following example:

\documentclass{beamer}

\usepackage{progressbar}

\begin{document}

\begin{frame}
  \begin{overprint}
    \begin{tikzpicture}[remember picture]
      \node<1-2> (progressbar) [inner sep=0,outer sep=0] {\progressbar[heightr=1, width=0.3\textwidth, emptycolor=white, filledcolor=red]{1}};
    \end{tikzpicture}
    \tikz[remember picture] \draw<2>[overlay] node at (progressbar.east) [inner sep=0,outer sep=0] {\progressbar[heightr=1, width=0.1\textwidth, linecolor=white!0, emptycolor=white, filledcolor=red, subdivisions=1, roundnessr=0]{1}};
  \end{overprint}
\end{frame}

\end{document}

The first slide (cropped) looks like this:

Progressbar

The second slide (cropped) looks like this (note the second \progressbar at around 85%, not 100):

Progressbar with incorrect relative position

How can I position the second \progressbar relative to the first so that they don't overlap (disregarding the ugly white border)?

0

1 Answer 1

7

Like this?

Result

The problem is that, by default, it is the center of your second progress bar what is placed at (progressbar.east). You want the left edge at that position, which is achieved by using [anchor=west] for that node. I.e.:

\documentclass{beamer}

\usepackage{progressbar}

\begin{document}

\begin{frame}
  \begin{overprint}
    \begin{tikzpicture}[remember picture]
      \node<1-2> (progressbar) [inner sep=0,outer sep=0] {\progressbar[heightr=1, width=0.3\textwidth, emptycolor=white, filledcolor=red]{1}};
    \end{tikzpicture}
    \tikz[remember picture] \draw<2>[overlay] node[anchor=west] at (progressbar.east) [inner sep=0,outer sep=0] {\progressbar[heightr=1, width=0.1\textwidth, linecolor=white!0, emptycolor=white, filledcolor=red, subdivisions=1, roundnessr=0]{1}};
  \end{overprint}
\end{frame}

\end{document}

Side note: I don't like very much that code, because it uses tikz code inside nodes (\progressbar command is indeed a complete tikzpicture), but I don't know how to avoid that in this case.

Update

The code can be improved a bit. You can draw the second overlay in the same tikzpicture than the first one. This removes the need of remember picture/overlay, and needs one less compilation:

\documentclass{beamer}
\usepackage{progressbar}

\begin{document}
\begin{frame}
  \begin{overprint}
    \begin{tikzpicture}
      \node<1-2> (progressbar) [inner sep=0,outer sep=0] {\progressbar[heightr=1, width=0.3\textwidth, emptycolor=white, filledcolor=red]{1}};
      \node<2>[anchor=west] at (progressbar.east) [inner sep=0,outer sep=0] {\progressbar[heightr=1, width=0.1\textwidth, linecolor=white!0, emptycolor=white, filledcolor=red, subdivisions=1, roundnessr=0]{1}};
    \end{tikzpicture}
  \end{overprint}
\end{frame}
\end{document}
2
  • Thank you very much. I was not aware of the default assumption (center). Feb 6, 2017 at 9:42
  • 1
    @AndreasUnterweger I noticed that the second \tikz is not required. I've updated the answer.
    – JLDiaz
    Feb 6, 2017 at 18:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .