1

Is there a way to make some content occupy its usual space and produce the same spacing around it, but not show up in any way? (In particular, putting the content in a \phantom box is a non-solution.)

The closest ad hoc semi-solution I can think of is to set the content color to the background color. However, this will not work if the background color is not uniform, and hidden text will show up when selecting text in the resulting PDF.

I am mostly interested in a solution for XeLaTeX.

Update. I have just realized how hard this can be to achieve. If I want to hide, for example, the left-hand side of an equation, simply adding braces around the left-hand side changes the spacing before the equality sign.

Alexey
  • 2,099
  • 2
    how general is the text to hide, if it is a box such as a table it's easy, if the hidden text starts mid-line in one paragraph, then spans several pages and ends in a cell of the third row of a table, then it is harder. – David Carlisle Oct 18 '20 at 16:26
  • 1
    with lualatex you can use https://tex.stackexchange.com/a/555697/2388 – Ulrike Fischer Oct 18 '20 at 16:26
  • @DavidCarlisle, let's assume, to begin with, that it is a left-hand side of an equation. – Alexey Oct 18 '20 at 17:01
  • @DavidCarlisle, a solution that would seem natural to me would work on the font/glyph level. It should be trivial to transform any font into a font with the same dimensions but with all glyphs blank. I wonder if something like this has been done. – Alexey Oct 18 '20 at 17:34
  • but that wouldn't remove rules, eg fraction bars of rule in tables etc and the text would still be available for cut and paste. – David Carlisle Oct 18 '20 at 20:03
  • for the left hand side of the equation you can simply use phantom, and for a visible version use a similar local box to get identical spacing. – David Carlisle Oct 18 '20 at 20:06
  • @DavidCarlisle, i do not get you. If i put the left-hand side of an equation in a \phantom box, or even simply in a group {}, this breaks spacing. – Alexey Oct 18 '20 at 21:02
  • 1
    @Alexey {..} may affect the spacing just as \mbox{one two} may use different space than one two but it's not really broken just affected and you can use the same spacing in visible and invisible versions. It depends on the use case. – David Carlisle Oct 18 '20 at 21:50
  • If you have a ligature fl and want to remove the l, it is unclear what "not affecting the placement of the rest" means: Display the f followed by space in the area that would normally be occupied by the ligature? Because there is no character "fl ligature without the l". – Heiko Theißen Nov 10 '22 at 12:59
  • @HeikoTheißen, I meant content that occupies a certain number of entire boxes. – Alexey Nov 10 '22 at 23:30

1 Answers1

0

You can use the transparent package and type:

\documentclass{article}
\usepackage{transparent}
\usepackage{lipsum}

\begin{document}

{ \transparent{0}\lipsum[1-2] }%

\lipsum[1-2]

\end{document}

In \transparent{value}, value goes from 0 to 1, where 1 is normal text, and 0 is transparent text.

  • This will not remove the text, you can still copy&paste it. – Ulrike Fischer Oct 18 '20 at 16:53
  • It would be a semi-solution, but the transparent package does not even seem to work with XeTeX. – Alexey Oct 18 '20 at 17:18
  • I turns out that transparent package does not work with XeLaTeX. More importantly, i've discovered that what i want to do may have no simple solution, because even grouping breaks spacing. – Alexey Oct 18 '20 at 17:29