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.

11
  • 3
    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. Commented Oct 18, 2020 at 16:26
  • 1
    with lualatex you can use tex.stackexchange.com/a/555697/2388 Commented Oct 18, 2020 at 16:26
  • @DavidCarlisle, let's assume, to begin with, that it is a left-hand side of an equation. Commented Oct 18, 2020 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. Commented Oct 18, 2020 at 17:34
  • 2
    @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. Commented Oct 18, 2020 at 21:50

2 Answers 2

2

I'm not seeing why you have rejected \phantom. I do not see any spacing difference in

code output

\documentclass{article} \usepackage{amsmath} \begin{document} \[ \begin{gathered} a+b=c\\ \phantom{a+b}=c\\ a+b=c \end{gathered} \qquad\text{nor in}\qquad \begin{aligned} a+b&=c\\ \phantom{a+b}&=c\\ a+b&=c \end{aligned} \] \end{document} 
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.

4
  • This will not remove the text, you can still copy&paste it. Commented Oct 18, 2020 at 16:53
  • It would be a semi-solution, but the transparent package does not even seem to work with XeTeX. Commented Oct 18, 2020 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. Commented Oct 18, 2020 at 17:29
  • Sounds to me you want this package: ctan.org/pkg/censor Commented Jul 28 at 3:50

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.