2

I want to hide something in a article. Hidden contents may be large enough to span muli-line multi-paragrph, and even muli-page.

I find a solution by mathspasha from How to replace a large block of text by an empty block of the same size? as the following code showes. It's simple and I like the idea(global switch and put hidden content to far left).

It works all fine except that text post \show begins a new paragraph. I wonder if something can be done to improve this solution to achieve a in-line phantom, I mean when hidden part finished, no new paragraph is created. Anyone can help me? Thanks.

CODE:

    \documentclass{article}
    \usepackage{lipsum}
    \long\def\hide#1\show{%
        \leavevmode\par
       \hspace*{-10000pt}\vbox\bgroup#1\egroup
       \par
    }
    \def\show{}
    \begin{document}
    Mark A
    \hide
    \lipsum[1-2]
    \show
    Mark B

And I hope the folowing two paragraphs have the same shape whet typeset.

|some text some text some text some text some text some text some text some text some text some text some text some text some text|

|some text \hide some text some text some text some text some text some text some text some text some text some text some \show text some text|

\end{document}

lyl
  • 2,727
  • Well, the code starts and ends with \par, so you have a new paragraph. However, also changing this will never work across pages. – campa Jun 15 '21 at 13:58
  • I tried removing \par. Then the code failed to work. So, how to improve it to phantom matters in-line and support multi-lines and multi-pages? – lyl Jun 15 '21 at 14:02
  • A luatex solution: https://tex.stackexchange.com/a/555697/82917 – campa Jun 15 '21 at 14:04
  • Thanks. Any other way other than lua ,especially works on the current code? – lyl Jun 15 '21 at 14:13
  • There is also the censor package and the comment package and some other packages in the category conditional compilation. – Marijn Jun 15 '21 at 15:28
  • @Marijn Seems that macros(\censer, \blackout) of package censor do not surport line-break(\\\, or \linebreak) in hidden text. Any method to solve it? – lyl Jun 17 '21 at 12:20
  • @lyl https://tex.stackexchange.com/questions/16003/phantom-and-line-break is related (uses the ulem package instead of censor). Or as an alternaitve solution you can choose to not use \newline at all and use \par (or empty lines) instead. – Marijn Jun 17 '21 at 12:49
  • use \par (or empty lines) will cause unexpected parindent. – lyl Jun 17 '21 at 13:57
  • @lyl \par\noindent creates a new paragraph without indentation. – Marijn Jun 18 '21 at 17:32
  • @Marjin Vertical spacing would be different between \newline and \par\noindent. And seems that this can not work with uline from package ulem. Any better way for this? – lyl Jun 19 '21 at 03:34

0 Answers0