0

My code:

\documentclass{beamer}
\usepackage[absolute,overlay]{textpos}
\begin{document}

\begin{frame}[fragile,t]
\frametitle{Demo}

\begin{textblock*}{\textwidth}(20mm,20mm)
\vspace{5mm}\hrule height 1mm\vspace{5mm}
\end{textblock*}

\end{frame}

\end{document}

Output:

enter image description here

Why does the \hrule not appear in the output? How can I fix it?

  • Is there any precise reason for using textblock? – egreg Aug 20 '19 at 21:20
  • @egreg I have multiple frames. Each frame has three pieces of content: (1) code block (2) another code block (3) commentary. I want these three pieces to remain fixed in all the frames and not jump around. I know I can solve this by using overlayarea in a single frame but I don't want to do that because these frames contain different ideas, so I want them to be separate frames. Combining them into a single frame does not reflect the notion that they contain different ideas (e.g., the frame number in the footer does not increment). – Lone Learner Aug 21 '19 at 5:15
1

The textblock* environment uses the properties of the content to determine the size of the box (even though the textpos manual states that the width of textpos* is absolute). The TeX primitive \hrule takes as width the width of the of the vertical box that encloses the \hrule instruction (see Why does a \hrule need text around it to be drawn?), which is empty in this case.

Possible solutions are to use \leavevmode (that sets the width of the box to \textwidth, see the linked question), or specify the width of the \hrule manually, or to use the command \rule with a specified width.

MWE below, with some examples of how textpos* handles different types of content for illustration purposes (using the showboxes package option).

\documentclass{beamer}
\usepackage[absolute,overlay,showboxes]{textpos}
\begin{document}

\begin{frame}[fragile,t]
\frametitle{Demo}
\color{green}\vspace{5mm}\hrule height 1mm\vspace{5mm}
\begin{textblock*}{\textwidth}(10mm,20mm)
\vspace{2mm}\hrule height 1mm\vspace{2mm}% zero width
\end{textblock*}
\begin{textblock*}{\textwidth}(10mm,30mm)
\vspace{2mm}\leavevmode\hrule height 1mm\vspace{2mm}
\end{textblock*}
\begin{textblock*}{\textwidth}(10mm,40mm)
\color{red}\vspace{2mm}\hrule height 1mm width \textwidth\vspace{2mm}
\end{textblock*}
\begin{textblock*}{\textwidth}(10mm,50mm)
\color{blue}\rule{\textwidth}{1mm}
\end{textblock*}
%further examples of textblock*
\begin{textblock*}{\textwidth}(10mm,60mm)% width of the character
\phantom{X}
\end{textblock*}
\begin{textblock*}{\textwidth}(10mm,70mm)% does not show

\end{textblock*}
\begin{textblock*}{\textwidth}(10mm,80mm)% full width
\color{black}X
\end{textblock*}
\end{frame}

\end{document}

enter image description here

  • Interesting. Generally the specified width is the width of the textblock (the height is always the height of the content), but in (slightly odd) cases such as these, where there's no text content, the outer box isn't drawn. I'm not sure if that's a bug or not (probably is). Your case, @Marijn, where the \phantom{X} has a tight box drawn, may be an old version of textpos – I don't see that when I try with v1.9.1. \leavevmode\vskip{XXXmm} is probably the best way of getting an empty box, with the outline drawn. – Norman Gray Aug 21 '19 at 10:10
  • See bitbucket.org/nxg/textpos/issues/12/… (though I fear I'm going to have to abandon bitbucket before long) – Norman Gray Aug 21 '19 at 10:19

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.