2

Related to this question, however, I was not able to solve my problem.

Let me give some background. I want to switch between the article style and a specific journal style. The journal style has specific commands that it uses for the abstract, proofs, appendices, etc. The variable \var states if I use the article style (0) or the journal style (1). Let us assume the command \ABSTRACT is used by the journal and it takes one argument as the actual abstract. So, normally you would print your abstract as \ABSTRACT{This is my abstract.}.

The following MWE does not work, and the error is that it is missing a closing argument }.

MWE

\documentclass{article}

\usepackage{ifthen}

\newcommand{\var}{1}
\newcommand{\ABSTRACT}[1]{\begin{abstract}#1\end{abstract}}

\begin{document}

\ifthenelse{\var = 1}{\ABSTRACT\bgroup}{\begin{abstract}}%
This is my abstract.%
\ifthenelse{\var = 1}{\egroup}{\end{abstract}}%

Some other text below the abstract.

\end{document}
  • 1
    That is why people asked why you wanted the bracket in eh other question, you said you wanted a group. But macro argument delimiters do not form a group and have to be {} explicitly they can not be \bgroup – David Carlisle Oct 17 '14 at 13:59
6

Macro delimiter braces have to be explicit catcode 1 and 2 characters, (typically {}) they can not be \bgroup\egroup. You can do

\documentclass{article}

\usepackage{ifthen}

\newcommand{\var}{1}
\newcommand{\ABSTRACT}[1]{\begin{abstract}#1\end{abstract}}

\begin{document}

\ifthenelse{\var = 1}
{\newcommand\myabstract[1]{\ABSTRACT{#1}}}
{\newcommand\myabstract[1]{\begin{abstract}#1\end{abstract}}}


\myabstract{This is my abstract.}

Some other text below the abstract.

\end{document}
| improve this answer | |

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.