TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the definition of a command appears the declaration of \@dblarg, as follows: \def\title{\@dblarg\CJ@title}. What exactly does \@dblarg do?

share|improve this question
It's a kernel command: \@dblarg{<command>}{<arg>} will expand to \{<command>}[<arg>]{<arg>}. – Gonzalo Medina May 17 '12 at 23:02
up vote 18 down vote accepted

It essentially checks if the token after \CJ@title is [ or not, in order to pass to the main command the same argument twice, if [ is not found. The command \CJ@title must be defined by


so that, with a call such as


the expansions will be (successively}

...<some complex action>...

and with a call such as


the expansions will be (successively}

...<some complex action>...

One can follow ...<some complex action>... by looking at the definition of \@dblarg:


So with \title{xyz} one has (one step on each line, I omit the expansions of \kernel@ifnextchar that are irrelevant here)


With \title[abc]{xyz} one has


(There's an extra pair of braces in the first case, but it should do nothing particular.)

How to do the same with xparse

With the xparse package one can obtain the same functionality with a clearer syntax (I assume this is done in a class or package file)



So no delimited argument is necessary.

share|improve this answer
Instead of using the command \def by \newcommand, what would happen? Anything change? – OSjerick May 17 '12 at 23:22
@osjerick You can't define a command with delimited arguments with \newcommand, so \def is necessary. – egreg May 17 '12 at 23:26
Thanks @egreg, now I'm learning all about creating classes, you could recommend me a manual or book about this, please? – OSjerick May 17 '12 at 23:31
@osjerick In the "LaTeX companion" there's material about this. – egreg May 17 '12 at 23:34
@osjerick: These are typically package-specific notations. Within the .sty file, @ is treated like a letter. So, it could be that the package author prefix certain internal commands with their initials, or perhaps even an abbreviation of the package name. For example, the keyval package author (David Carlisle) decided to use a KV@ prefix, which was duplicated in the xkeyval package using XKV. – Werner May 18 '12 at 5:26

This is an easy way of allowing optional arguments to some other function/macro.

For example, using your case of \def\title{\@dblarg\CJ@title}, you can either use

\title{some title}

without an optional argument, or use

\title[some optional title]{some title}

with an optional argument. "Easy" here refers to the fact that if you don't specify the optional component (like in the former example), it defaults to

\title[some title]{some title}

thereby converting single-argument responses into double-arguments. The macro \CJ@title is appropriately defined to manage both arguments and could have the form:


This is typically the case with sectional commands that have an optional argument: \section[<ToC entry>]{<body entry>}. If you don't specify the optional argument, the <body entry> still makes its way into the ToC. How? \@dblarg.

Here are the formal definitions contained within latex.ltx - you'll find its use inside \@startsection, just as an example:

share|improve this answer
Thanks! @Werner. – OSjerick May 17 '12 at 23:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.