Please can someone explain to me why I'm getting the following compiling error
LaTeX3 Error: Command '\sc' already defined!
\documentclass[10pt]{book}
\NewDocumentCommand{\ch}{om}{
\IfNoValueTF{#1}{
\chapter{#2}
}{
\chapter{#2}\label{ch:#1}
}
}
\NewDocumentCommand{\sc}{om}{
\IfNoValueTF{#1}{
\section{#2}
}{
\section{#2}\label{sc:#1}
}
}
\begin{document}
\ch{AAA}
\sc{BBB}
\end{document}
Best Answer
\sc
is a legacy font command based on\scshape
that is used in thebook
class for compatibility with LaTeX2.09. You could use another name such as\Sc
but beware such shorthands make it harder to use standard section features such as the*
form for the unnumbered variant, and the optional argument for the table of contents version of the header.Also as you are adding a lot of white space (in a standard context not in
\ExplSyntaxOn
) these space tokens can affect the output, considerWhich produces
Where the
\Sc
version is producing the heading as if the previous paragraph ended with additional space as shown in section 2 as opposed to the intended layout produced by\section
in section 3.