I am looking for a method to create such an environment:

\begin{environmentName}{Visible text for program}

Invisible text for program


Invisible text has to be "inside" environment (can't be argument in {}).

I tried to use comment environment inside my environmentName definition, but it didn't work.

  • If I understand what you mean you want an environment that will make TeX process Visible text for program and ignore Invisible text for program, is that it? – Phelype Oleinik Jan 19 '18 at 13:05
  • In PDF file you will just see text: "Visible text for program". "Invisible text for program" will be treated as normal % comment – HiddenHanitatis Jan 19 '18 at 13:28

It seems like an overkill but you can use \NewEnviron from the environ package:





\begin{myenv}{This will be printed.}
This will not be printed,
even if you write wrong stuff like \misspelledorundefinedmacro.


Depending on how the environment is used this might need some adjustments for correct spacing.

  • @HiddenHanitatis did you even chaech what campas example does? This does exaxtly what you are asking for, everything inside the env is ignored, including the macros that does not exist. – daleif Jan 19 '18 at 13:51

You can use the comment package.

Any text between \begin{comment} and \end{comment} will be discarded.

Otherwise you can put your "invisible" text inside an \iffalse ... \fi, so that TeX will skip anything inside it.


enter image description here



Visible text for program


Invisible text for program


Another visible text for program


Another invisible text for program


  • I know how to use comments. It's just one-time solution. – HiddenHanitatis Jan 19 '18 at 13:42
  • 1
    @HiddenHanitatis Oh, sorry for wasting time trying to help you. – Phelype Oleinik Jan 19 '18 at 14:16
  • @PhelypeOleinik: A rule of thumb: Don't try to answer unclear questions -- you won't get much 'reward' – user31729 Jan 19 '18 at 19:40
  • @ChristianHupfer Good point... Thanks for the advice :) – Phelype Oleinik Jan 19 '18 at 20:17

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.