6

I am attempting to convert a document from one class to another. In the original class, I am able to use TikZ and PGFPlots for my graphics. However, in the new class, I receive the following error:

! Missing number, treated as zero.
<to be read again> 
                   }
l.51 \section{Introduction}

If I remove all of the \section{} commands, the document compiles fine. Furthermore, the \section*{} commands do not cause an error.

The class .cls file for which I am experiencing the errors can be found at: https://bitbucket.org/lgriffiths/lyx-classes/src/df41b5298566/_miktex_tex_latex/ifasd/ifasd.cls

MWE

\documentclass{ifasd}
\usepackage{lipsum}
\usepackage{tikz}
\begin{document}

\section*{Testing One}
\lipsum[1]

\section*{Testing Two}
\lipsum[2]

\section{Testing Three}
\lipsum[1]

\end{document}
  • It would be much easier for us to help you if you post a MWE that illustrates the error. To see what's entailed in a MWE look at What makes a good MWE – A.Ellett May 23 '13 at 4:01
  • Thank you for the tip, I will include a MWE from now on. – Eric May 23 '13 at 4:13
  • It seems the issue arises with tikz or pstricks. Also, it seems that the package titlesec seems to be the culprit. But, I haven't found anything in my searches about why the titlesec package should create problems with either tikz or pstricks. – A.Ellett May 23 '13 at 4:15
  • 1
    An article class document which uses the packages titlesec, lipsum, and tikz seems to think there's a missing parenthesis when using the \titleformat command and calling \MakeUppercase in the manner called by your class. – A.Ellett May 23 '13 at 4:22
  • As a work around, I removed the \MakeUppercase in the \titleformat command and typed my section headings in uppercase within the *.tex document. Its a brute-force type solution, but it works for now. I will post a more elegant solution if I come up with one. – Eric May 23 '13 at 4:43
4

There is an error in the specification for the section titles: the \MakeUppercase instruction should go in the last mandatory argument of \titleformat. Where it is now it doesn't make sense.

\titleformat{\section}[hang]
  {\normalsize\normalfont\bfseries}
  {\thesection}
  {6pt}
  {\MakeUppercase}
3

try

\documentclass{ifasd}
\usepackage{lipsum}
\usepackage{tikz}
\titleformat{\section}[hang]%
  {\normalsize\normalfont\bfseries\uppercase}%
  {\thesection}{6pt}{}
\begin{document}
[ ... ]
1

Whittling down ifasd, the following MWE has an apparent conflict between tikz (or pstricks) and how \MakeUppercase is being used:

\documentclass{article}
\usepackage{titlesec}
\titleformat{\section}[hang]%
  {\normalsize\normalfont\bfseries\MakeUppercase}%
  {\thesection}{6pt}{}
\pagestyle{empty}
\usepackage{lipsum}
\usepackage{tikz}
\begin{document}
\tableofcontents

\section{Testing One}
\lipsum[1]

\end{document}

Here's a bit of a work around until someone comes up with a better solution.

\documentclass{article}
\usepackage{titlesec}
\titleformat{\section}[hang]%
  {\normalsize\normalfont\bfseries}%
  {\thesection}{6pt}{}
%..%'
\usepackage{xparse}
\let\oldsection\section
\RenewDocumentCommand\section{ som }{%
    \IfBooleanTF{#1}
        {\oldsection*{#3}}
        {\IfNoValueTF{#2}
         {\oldsection{\MakeUppercase{#3}}}
         {\oldsection[#2]{#3}}}}
%..%'
\pagestyle{empty}
\usepackage{lipsum}
\usepackage{tikz}
\begin{document}
\tableofcontents

%\MakeUppercase This one
\section{Testing One}
\lipsum[1]

\end{document}

So, in terms of your class, you can write something along the lines of

\documentclass{ifasd}
%..%'
\usepackage{xparse}
\let\oldsection\section
\RenewDocumentCommand\section{ som }{%
    \IfBooleanTF{#1}
        {\oldsection*{#3}}
        {\IfNoValueTF{#2}
         {\oldsection{\MakeUppercase{#3}}}
         {\oldsection[#2]{#3}}}}
%..%'
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}

\section*{Testing One}
\lipsum[1]

\section*{Testing Two}
\lipsum[2]

\section{Testing Three}{}
\lipsum[1]

\end{document}

provided you've gone into ifasd and removed the apparently confounding \MakeUppercase from the \titleformat commands.

The idea for writing \section this way is due to an answer by @egreg to a question of mine.

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.