General/newcommand, how to make it invisible

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Faboom
Posts: 1
Joined: Sun Jun 15, 2008 5:05 am

/newcommand, how to make it invisible

Post by Faboom »

Hello,
currently im writing my masters, and to structure the thesis Im writing small summaries above my paragraphs.
Throughout the document creation they shall be visible, but afterwards id like to make them vanish.

For that matter i created a new command:

Code: Select all

\newcommand{\pSum }[1]{
\textbf{#1} \newline
}
My question: is there a command that makes the arguments invisble?
or better: defines the arguments as comments (%)?

cheers!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

/newcommand, how to make it invisible

Post by gmedina »

If I understood your question, then one possibility is to use a switch and an ifthen construct, as the following example suggests:

Code: Select all

\documentclass{article}
\usepackage{ifthen}

\newcommand{\mycomment}[1]{\textbf{#1}}
\newcommand{\switch}[1]{%
  \ifthenelse{\equal{#1}{0}}{\renewcommand{\mycomment}[1]{}}{}}
\switch{1}

\begin{document}

\mycomment{First comment}

text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 

text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 

\mycomment{Second comment}

text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 

text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 

\mycomment{Third comment}

text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 

text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 
\end{document}
This is the idea: the \mycomment command takes one argument and prints it in boldface type.
I also defined a \switch command. If this switch is set to zero (0) then, mycomment will be redefined and will do nothing. On the other hand, if you set the argument of the switch command to one (1), then \mycomment will act as expected.

In the example code I posted, if you change

Code: Select all

\switch{1}
to

Code: Select all

\switch{0}
then all the comments (introduced with the \mycomment command) will "vanish."
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply