2

I am using the IEEE Transactions on Magnetics document class in LYX and am having difficulties with the "Part" section. All other sectioning types (section, subsection, paragraph, etc.) work fine, but when I add a "Part" section and try to view I get the following message:

\part

     {Digital Control}

The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx), type I and the correct spelling (e.g., I\hbox). Otherwise just continue, and I'll forget about whatever was undefined.

Is there something that I can add to my preamble to fix this? Thanks in advance for any help.

3
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – jjdb
    Commented May 28, 2017 at 20:16
  • 1
    I can't find any mention of the \part command in the documentation to the IEEEtrans class. So probably it is not implemented for it (as it is the case for \chapter)
    – jjdb
    Commented May 28, 2017 at 20:26
  • I was afraid of that. It's weird that 'Part' appears in the sectioning drop-down menu, but I can't use it. Is there any way to easily implement it? I really like the IEEE format for the type of document I am writing. I would just like to be able to differentiate between two clearly separate parts and have it show in the TOC. Commented Jun 3, 2017 at 23:38

1 Answer 1

1

Apparently the IEEEtran class has no \part command although is is based on the article class which does.

A possible fix would be to re-include the definitions of the article.cls class file into your document, like:

\documentclass{IEEEtran}
\makeatletter
\newcounter {part}
\renewcommand \thepart {\@Roman\c@part}
\newcommand\part{%
   \if@noskipsec \leavevmode \fi
   \par
   \addvspace{4ex}%
   \@afterindentfalse
   \secdef\@part\@spart}
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \Large\bfseries \partname\nobreakspace\thepart
       \par\nobreak
     \fi
     \huge \bfseries #2%
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}
\def\@spart#1{%
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \huge \bfseries #1\par}%
     \nobreak
     \vskip 3ex
     \@afterheading}
\newcommand*\l@part[2]{%
  \ifnum \c@tocdepth >-2\relax
    \addpenalty\@secpenalty
    \addvspace{2.25em \@plus\p@}%
    \setlength\@tempdima{3em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      {\leavevmode
       \large \bfseries #1\hfil \hb@xt@\@pnumwidth{\hss #2}}\par
       \nobreak
       \if@compatibility
         \global\@nobreaktrue
         \everypar{\global\@nobreakfalse\everypar{}}%
      \fi
    \endgroup
  \filetter}                                                                                                                                                                    
\makeatother                                                                                                                                                                    
\renewcommand\partname{Part}                                                                                                                                                    

\usepackage{lipsum}                                                                                                                                                             
\title{A way to use the 'Part' command in Latex}                                                                                                                                
\author{John Doe}                                                                                                                                                               
\begin{document}                                                                                                                                                                
\maketitle                                                                                                                                                                      
\begin{abstract}                                                                                                                                                                
\lipsum[1]                                                                                                                                                                      
\end{abstract}                                                                                                                                                                  
\part{First Part of the Article}                                                                                                                                                
Some text right after the part. Maybe some summary or so. \lipsum[1]                                                                                                            

See that there was no indentation after the part, which just comes after the                                                                                                    
first paragraph of written words.                                                                                                                                               
\section{First section}                                                                                                                                                         
\lipsum                                                                                                                                                                         
\section{Second section}                                                                                                                                                        
\lipsum                                                                                                                                                                         
\part{Second Part of the Article}                                                                                                                                               
This part only has a single section.                                                                                                                                            
\section{Last section}                                                                                                                                                          
\lipsum                                                                                                                                                                         
\end{document}                                                                                                                                                                  

As I've just c&p'ed the corresponding parts of the code from article.cls, there can still be possible bugs (I actually had to change one or to \newcommand into \renewcommand to get this working, and also to include the code between \makeatletter/\makeatother, where I've probably included more than necessary).

Maybe it would be better to define your own article class instead, and include all the features you like from the IEEEtran.cls file.

2
  • Damn! Thanks for that! I guess I probably would be better off creating a custom class, I was just hoping to be able to avoid that. Oh well, such is the way of things. I really appreciate your help with this. It'll make creating a custom class much easier! Commented Jun 4, 2017 at 22:12
  • 1
    Best ask for help on how to implement the features for the custom class on this site step-by-step, as I am not 100% sure if everything in the code above is 100% kosher.
    – jjdb
    Commented Jun 5, 2017 at 7:21

You must log in to answer this question.

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