I'm wondering if there's a way to define a command so that, when a flag is specified, I can ignore everything but text within the tag. For instance, if I had
...
This is a \dontignore{bird}.
I would want the output to be either "This is a bird." or "bird" depending on whether or not I switch this flag.
Is this doable? Obviously surrounding everything but the text I want in some tag would be easy, but that seems quite inelegant.
Edit: Here's exactly what I have in mind:
\documentclass{article}
\newcommand{\dontignore}[1]{...}
\begin{document}
Hello world. This is my full document with a lot of extra bells and whistles and lines. But in the end, \dontignore{this is all that matters}.
\end{document}
With the flag off, the output should be
Hello world. This is my full document with a lot of extra bells and whistles and lines. But in the end, this is all that matters.
Otherwise,
this is all that matters
Optimally, I would also be able to tell LaTeX not to ignore things like section and enumerate/itemize/item commands as well, as follows
\documentclass{article}
\newcommand{\dontignore}[1]{...}
\begin{document}
\section{First part}
Hello world. This is my full document with a lot of extra bells and whistles and lines. But in the end, \dontignore{this is all that matters}.
\begin{enumerate}
\item \dontignore{Item 1}
\item Something like \dontignore{Item 2}
\end{enumerate}
\end{document}
to produce either everything (eg, with dontignore defined as \newcommand{\dontignore}[1]{#1}) or otherwise (with some flag specifying section, enumerate, etc.) as follows
1 First part
this is all that matters
- Item 1
- Item 2
This is a
part depending on the context?...
before the line and.
at the end? What is with text following that line? Do you want to ignore the wholedocument
environment except for the\dontignore
parts? Can you provide a full minimal working example (MWE)?\mycmd{This is a \dontignore{bird}}
Or do you want the entire document to disappear outside of the\dontignore{}
tags?This is a
, but optimally I would like to be able to compile and tell the compiler to ignore all text outside of specific commands or environments.