Combining two commands in a new command in Latex

Viewed 453

I am trying to create a new command that will replace text with a blank line to write on. Essentially, the lovechild of, \underline and \phantom if it can be toggled on and off that would be even better but I seem to have a misunderstanding of how macros work in latex.

My crappy code is below

\newcommand{\rmv{}}{\Underline{\phantom{}}}
1 Answers

You're macro needs to know what text you want in the gap, so it needs an argument. The syntax to pass argument to the new macro is

\newcommand\macroname[number of arguments]{use the argument with #1 etc.}

\documentclass{article}

\newif\ifgaps
\gapstrue % comment/uncomment to toggle

\newcommand{\rmv}[1]{%
  \ifgaps%
    \underline{\phantom{#1}}%
  \else%
    #1%
  \fi%
}

\begin{document}

test \rmv{test} test

\end{document}

(to automatically create two versions of your pdf with and without the gaps, you could use something similar to https://topanswers.xyz/tex?q=583 )

Related