0

Here is MWE showing my problem:

\documentclass[11pt]{article}
\usepackage[absolute,overlay]{textpos}
\TPGrid{1}{1}

\begin{document}
  Line 1
  \begin{textblock}{1}(0,0)
    My overlay
  \end{textblock}
  Line 2
\end{document}

After building this document you can see, that the "Line 2" line gets printed partially over the "Line 1".

My question is: How to avoid this vertical shift?

Please, don't propose to add \vspace{...}, since for my purposes I need exact positioning (animation in beamer).

2 Answers 2

1

Textblocks are really supposed to be used in vertical mode, and a textblock forces a new paragraph if it starts in horizontal mode, so this is to some extent unsupported territory. The TeXnical reason (thinking about this briefly) is that the textblock results in the ‘Line 2’ becoming separated, within the paragraph, from the ‘Line 1’ above it, so that TeX ‘forgets’ that it's in the middle of a paragraph, and so that has to add inter-paragraph spacing (ie, there isn't an upward vertical shift here, as much as a lack of the downward inter-paragraph space which TeX would otherwise add).

However it wouldn’t be unreasonable in this situation, nor necessarily particularly hard, for textpos instead to adjust spacing and penalties so that a textblock in horizontal mode ends up acting more like a \par (that would be me, editing it). That's not going to happen immediately, though.

The most robust solution in this case, though, and with the current version of textpos, would be to move the textblock, somehow/somewhere, so that it ends up between paragraphs. It'll be happier there! In the beamer context (though I don't have much experience with beamer), it might be that putting the textblock (or textblocks?) all together at the beginning of the frame, might be worth a look.

I've added an issue in the repo. Thanks for reporting this.

Edit: clarified 'wouldn't be unreasonable' remark.

9
  • Thank you for the explanations and for the issue. I'm totally OK with the new paragraph. In fact I also tried to put \par prior to \begin{textblock} manually. My concern is only the unexpected upward shift. (\begin{textblock} becomes something like \par\vspace{-1.1...mm}). Jan 24, 2020 at 14:31
  • I've adjusted the answer slightly: it would be better for a textblock in horizontal mode to act more like a \par. Right now, it makes only a rather half-hearted attempt at this (because it's not really supported, and this is better than nothing). Jan 24, 2020 at 14:40
  • 1
    Oooh, I've just noticed David Carlisle's answer to another question, where he suggests using \vadjust. Jan 24, 2020 at 14:42
  • 1
    I've created a 1.10b1 release -- see the issue. Feb 4, 2020 at 13:28
  • 1
    Excellent -- thanks for testing. Then I'll release 1.10 shortly, after tidying up a couple of other things. Feb 12, 2020 at 12:15
1

Put apart the textblock.

\documentclass[11pt]{article}
\usepackage[absolute,overlay]{textpos}
\TPGrid{1}{1}

\begin{document}
  Line 1

  Line 2
  \begin{textblock}{1}(0,0)
    My overlay
  \end{textblock}
\end{document}
1
  • Simple, :) but unfortunately not possible in my case. E.g. with large paragraphs the overlay will end up on the wrong page. In my case, the beamer overlay specification <+> will not work correctly. Is where any other solution without moving textblock? Jan 24, 2020 at 11:19

You must log in to answer this question.

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