0

What I want is something like this:

\hidemyenvironment \begin{myenvironment} This text is not displayed, it is "hidden". \end{myenvironment} \showmyenvironment \begin{myenvironment} This text is visible! \end{myenvironment} 

I want the command \hidemyenvironment to make it not appear on the PDF, while the command \showmyenvironment will make it reappear again. I was thinking of using an if statement so I can switch it on and off in the document and have some environments displayed and others hidden.

Here is a MWE:

\documentclass{article} \usepackage[utf8]{inputenc} \makeatletter \newif\if@hidemyenvironment \newcommand{\hidemyenvironment}{\@hidemyenvironmenttrue} \newcommand{\showmyenvironment}{\@hidemyenvironmentfalse} \newenvironment{myenvironment}{ \if@hidemyenvironment % some code to ignore the environment? \else % just show whatever is in the environment/ do nothing \fi }{} \makeatother \begin{document} Hello!\par \hidemyenvironment \begin{myenvironment} Hidden text! \end{myenvironment} \par \showmyenvironment \begin{myenvironment} \begin{equation} x+y=z \end{equation} \end{myenvironment} \end{document} 

Is there perhaps a command that can comment everything inside the environment, or another solution? I would prefer that you can write equations, tables and other things inside the environment and that it is only used to hide/ display parts of the output PDF.

The output of the MWE should be:

enter image description here

0

1 Answer 1

2

You can do this using the comment package.

\documentclass{article} \usepackage{comment} \begin{document} Hello! \excludecomment{myenvironment} \begin{myenvironment} Hidden text! \end{myenvironment} \includecomment{myenvironment} \begin{myenvironment} \begin{equation} x+y=z \end{equation} \end{myenvironment} \end{document} 

Feel free to add

\newcommand{\hidemyenvironment}{\excludecomment{myenvironment}} \newcommand{\showmyenvironment}{\includecomment{myenvironment}} 

Also, your use of \par is unnecessary.

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.