I wish to use the xkeyval package to overide the 9 arguments limit and to clarifiy the different arguments (compulsory or optional). In my arguments/parameters, I have complete paragraphs possibly including \par or \\\\. I know that some macros accepts \par, others don't, to avoid hidden problematic nestings I understand. It seems that the prefix \long allows to have \par within arguments. In the implementation part of the doc, I see plenty of these \long macros.

Does that guarantee I can use \par in the arguments/value within the package xkeyval?

  • 2
    Welcome to TeX.SX! Did you try it? ;-)
    – user31729
    Commented May 31, 2015 at 9:38
  • Yes it should work. Alternatively, if you are using aTeX and use \newcommand instead \def to define macros then this is automatic. Other differences are discussed in What is the difference between \def and \newcommand?.
    – user30471
    Commented May 31, 2015 at 9:52
  • @ChristianHupfer I am trying ! But, since I don't know how to use xkeyval, if one says "no way, it won't work" I would try something else :) Commented May 31, 2015 at 10:28
  • @user1771398: Well, it works, as shown in my answer ;-)
    – user31729
    Commented May 31, 2015 at 10:30
  • @ChristianHupfer Thanks for the pedagogic document that allow to see what works and what doesn't ! Now I feel I understand the 'xkeyval' and application to text with '\par', '\\' etc. Together with Andrew, I also better understand the nature of '\newcommand' and '\newcommand*' Commented May 31, 2015 at 16:02

1 Answer 1


\newline or \\ after an empty line would be an error anyway, but otherwise it's ok (if really necessary ;-)). \par or empty lines will do in a key as well.

Just mustn't define the command \foocmd as \newcommand*{} but as \newcommand.

If you want to be on the safe side, use \NewDocumentCommand{\foocmd}{+o+m}{...} from the xparse package, the + character allows explicitly \par etc. in the argument then.

Some background

TeX's \def command does not allow arguments with a parbreak etc, unless the \def usage is preceeded with \long (see the example below).

LaTeX's \newcommand is basically a wrapper for \long\def..., so it does allow \par, empty lines and \newline and \\, whereas \newcommand* is the 'un\long' version of it, disallowing this features.






  The key had the value \KVfookey

Mandatory argument was #2


  The key had the value \KVfookey

Mandatory argument was #2


\newcommand*{\fooother}[2][foo={A long

Arg was #2%

\newcommand{\foocmd}[2][foo={A long


The key was \KVfookey

And this is the 2nd argument: #2%


% Won't work, since arg isn't long

%key}]{Hello World again}

% Won't work, since defined with `\newcommand*` .. i.e not \long\def...
%\fooother{Hello World}

\item Using a \verb+\long\def+ command -- works

key}]{Hello World again}

\item Using a \verb+\newcommand+ command -- works

\foocmd{Hello World}

\foocmd[foo={A very long command  \newline\newline


key}]{... which is absolutely useless}



enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .