# How to renew section commands in latex3

I'm trying to rewrite section commands using LaTeX3. For testing purpose, what I did is basically this:

\ProvideDocumentCommand \p { o m }
{   \IfNoValueTF{#1}
{ %
\paragraph{\textsf{#2}}
}
{ %
\paragraph[#1]{\textsf{#2}}
}
}


But I want to rewrite the \paragraph command so I could reuse any customization in a standard way. I've done some digging and obviously I need to get a grip on expl3, I saw multiple ways of doing this, like here but I'm trying to reach something that might be distributed as a .sty class. I dig into skrapport class, but there's too much information. Is there anyone that could explain me step by step the process from the \ProvidesExplClass to command rewriting like any kind of section or a simple \cite?

• Why? Why no simply learn how the sectional commands are actually being done, and then learn to configure those in a propper manner. – daleif Oct 3 '13 at 9:40
• We've not yet got a fully-working set of class commands for LaTeX3 work. As such, we are still dependent on a lot of LaTeX2e stuff: I'm not sure there is currently a good alternative to using LaTeX2e commands mixed with LaTeX3 ideas. – Joseph Wright Oct 3 '13 at 11:32
• @daleif I'm not sure I understood you right, but that's the aim of my question: "configure section commands in a proper manner, using expl3..." – nadous Oct 3 '13 at 11:53

The skrapport class defines sections with a simple pattern:

\DeclareDocumentCommand\paragraph{som}{
\__skrapport_generic_section:nnnnn{paragraph}{4}{#1}{#2}{#3}
}


The first argument to \__skrapport_generic_section:nnnnn is the associated counter name level, the second the level, the third the possible *, the fourth the possible optional argument (short title) and the fifth, finally, is the full title.

Thus all you need, in order to change font for the \paragraph titles is

\ExplSyntaxOn
\RenewDocumentCommand\paragraph{som}{
\__skrapport_generic_section:nnnnn{paragraph}{4}{#1}{#2}{\sffamily#3}
}
\ExplSyntaxOff


in your document preamble. Here's an example document.

\documentclass{skrapport}

\ExplSyntaxOn
\RenewDocumentCommand\paragraph{som}{
\__skrapport_generic_section:nnnnn{paragraph}{4}{#1}{#2}{\sffamily#3}
}
\ExplSyntaxOff

\begin{document}

\paragraph{This is a paragraph title}
Text follows.

\end{document}


• Yes, but that would require me to use the skrapport document class, which I don't want to. What I need is a .sty file I can put all my customizations and simply call with \usepackage But that's the right direction, skrapport.cls has a \cs_set:Nn\__skrapport_generic_section:nnnnn calling all bunch of stuff. That the part of code I need to dig. – nadous Oct 3 '13 at 11:59
• @nadous What class do you intend to use? Changing the formatting of titles is better done with a package such as titlesec. – egreg Oct 3 '13 at 12:10
• Uh yeah! You're absolutely right, the titlesec package might very well suit my needs. – nadous Oct 3 '13 at 14:20