0

I want to hide some text but :

  • I don't want the hidden text to take space

  • I still want that LaTeX parse the content (to keep numbering)

I have found this solution :

\vphantom{\hphantom{text}}

This work perfectly but is there any better way to do it (I feel like latex probably already have a command for that and I just need to find it's name) ?

Matheod
  • 450
  • 3
  • 14
  • 2
    If you say you want to keep numbering, maybe more information on what you are actually trying to do would be helpful. – asante Aug 07 '19 at 20:46
  • I have my main document containing a lots of things. This will generate my main pdf. But I will also want to generate some pdf with only some part of my document or without some part of my document but I need everythings else to stay the same so I need to have all counter to be the same that the main document. – Matheod Aug 07 '19 at 20:52
  • @Matheod best way is probably to put each section in a separate file and use \includeonly to specify which sections you want to use. All numbering is then preserved. – David Carlisle Aug 07 '19 at 20:59
  • \includeonly might work in some case but not all because it require a new page. – Matheod Aug 07 '19 at 21:02

2 Answers2

2

The phantom construct makes a zero-sized box, but it can affect the spacing of surrounding constructs, see the middle column, below. You can simply set the text in a box, then not use the box.

enter image description here

\documentclass{article}

\begin{document}

\begin{tabular}{|*{3}{p{2cm}|}}
\hline
a

b
&
a

\vphantom{\hphantom{text}}

b
&
a

\sbox0{text}

b
\\
\hline
\end{tabular}


\end{document}
David Carlisle
  • 757,742
  • Section seems to make sbox broke. Example :

    ` \documentclass{article}

    \begin{document}

    \section{a}

    \sbox0{b

    c

    \section{d}

    e}

    \section{f}

    \end{document} `

    – Matheod Aug 07 '19 at 21:12
  • @Matheod yes same would be true of \hphantom as you said that worked perfectly I assumed that you only needed horizontal mode material. You can use \sbox0{\vbox{...\section...}} but there are still other things that would fail eg \begin{figure} – David Carlisle Aug 08 '19 at 09:07
1

Here's something I've been using for years. It may not be exactly what you want, but it works for my.

\newcommand{\noop}[1]{}

It takes one argument and does absolutely nothing with it.

I use it for "commenting out" text or equations that I might want to use, and might not. It's useful for developing docs. When my doc is ready, I just delete all the \noop blocks.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. – Community Aug 28 '22 at 21:43