3

In the following code, I can hide in the paper any piece of text except the ones coming from the command \showthis.

Is there a way to hide output coming from other materials like pictures and tikz drawings for example ?

This would be to do a preprocessing for a tool to automate corrections of tests.

\documentclass[12pt]{article}

\usepackage{xcolor}

\makeatletter
\newcommand{\globalcolor}[1]{%
  \color{#1}\global\let\default@color\current@color
}
\makeatother

\AtBeginDocument{\globalcolor{white}}

\usepackage{lipsum}

\newcommand\showthis{{\color{black} JUST SHOW ME}}

\newcommand\blabla{bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...}


\begin{document}

\lipsum[2]

\showthis{}

\lipsum[2]

\showthis{}

\blabla{} \showthis{} \blabla{}

\lipsum[2]


\end{document}
  • Hide on paper or in the PDF? For example, your approach hides the text on paper, but it still exists in the PDF. – Steven B. Segletes Mar 7 '18 at 10:51
  • 3
    Possible duplicate of Output Content ONLY from a Single Macro – Phelype Oleinik Mar 7 '18 at 11:06
  • I have edited my question. I am only concerned by the paper version. – projetmbc Mar 7 '18 at 11:43
  • If only the paper version is the issue, then why isn't what you have already done (in the example provided in your question) good enough? – Steven B. Segletes Mar 7 '18 at 12:07
  • My example doesn’t take care of none textual materials. – projetmbc Mar 7 '18 at 12:10
1

Is it something like thqt you are looking for ?

Hidetrue

enter image description here

Hidefalse

enter image description here

\documentclass[12pt]{article}
\usepackage{xcolor}
\newif\ifHide
\Hidetrue % hide the text 
%\Hidefalse % show the text

\usepackage{lipsum}

\newenvironment{Hidethis}{%
    \ifHide
    \begingroup\color{white}
    \fi}{%
    \ifHide
    \endgroup
    \fi}

\newcommand\blabla{bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...}


\begin{document}

\begin{Hidethis}
\lipsum[2]
\end{Hidethis}

JUST SHOW ME

\begin{Hidethis}
\blabla{}
\end{Hidethis}
JUST SHOW ME
\begin{Hidethis}
\blabla{}
\end{Hidethis}

\begin{Hidethis}
\lipsum[2]
\end{Hidethis}
\end{document}
  • Thanks. But this solution is only for text. How can I manage pictures and other none textual materials. – projetmbc Mar 7 '18 at 12:04
  • @projetmbc do you the hidden parts disappear and take no more room or turn white but stay in place. – Tarass Mar 7 '18 at 22:09
  • Thanks for your solution but I am looking for a soft solution which uses a macro for the parts to be displayed instead of a macro for things to be hidden. – projetmbc Mar 11 '18 at 13:46
  • @projetmbc OK but do you want that the displayed parts stay at there places (hidden text takes his room) or hidden text vanishes and the displayed parts stick together? Am I clear ? – Tarass Mar 11 '18 at 14:17
  • @Tarras Yes I want that hidden texts take their room. – projetmbc Mar 12 '18 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.