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.
\phantombox, or even simply in a group{}, this breaks spacing. – Alexey Oct 18 '20 at 21:02{..}may affect the spacing just as\mbox{one two}may use different space thanone twobut 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:50fland want to remove thel, it is unclear what "not affecting the placement of the rest" means: Display theffollowed 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