0

I have a command that works with this syntax:

\startmycommand[{

nononononononononononon
nononononononononononon
nononononononononononon

}]\endmycommand

A user has provided a(n) (excellent) simplification to \startmycommand, as you can see above:

\newcommand\mynewstartcommand{%
  \expandafter\startmycommand
  \expandafter[%
  \expandafter{%
  \iffalse}\fi
}%

How can I do the same for }]\endmycommand?

  • Could you explain what the command does and why it has this uncommon syntax? Looks more like an environment to me … and why can’t you use simple search&replace to change the code in your document? – Tobi Aug 1 '15 at 12:27
  • Hi, @Tobi. I agree, it's like an environment. This is the syntax for \twocolumn, that works with: \twocolumn[{ nononononon }] I don't know why this command requires brackets AND braces, but doesn't work if some of them are removed. – Fabricio Pio Aug 1 '15 at 12:30
  • 1
    Actually \twocolumn does not require the braces. Only if the argument contains brackets the braces ar needed. I.e.: \twocolumn[ok], \twocolumn[not [ok]], \twocolumn[{now [ok]}]. This is because TeX can’t finde the end of the argument otherwise and this rule applies to all optional arguments. – Tobi Aug 1 '15 at 16:24
2

Maybe you are looking for something like the following example:

\long\def\mynewstartcommand#1\endmycommand{%
  \startcommand[{#1}]\endmycommand
}

\mynewstartcommand

  nononononononononononon
  nononononononononononon
  nononononononononononon

\endmycommand

But the question is not too clear, what's the regular content of the argument, what's the purpose of the empty lines in the argument, what is the desired syntax?

0

@Heiko Oberdiek, your answer has worked fine here.

A minimal example to ilustrate how I'm using it – with your suggestion:

\documentclass[a4paper, twocolumn, twoside]{article}
\usepackage{lipsum}

\long\def\mynewstartcommand#1\endmycommand{%
  \twocolumn[{#1}]\vspace*{10 mm}
}

\begin{document}


\mynewstartcommand

\begin{minipage}{0.795\paperwidth}
\begin{minipage}[t][][b]{0.45\linewidth}
\lipsum[1]
\end{minipage}\qquad~\qquad
\begin{minipage}[t][][b]{0.45\linewidth}
\lipsum[2]
\vspace*{40 mm}
\end{minipage}
\end{minipage}


\lipsum[3]

\endmycommand


\end{document}

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.