Text FormattingUse of '\makeatletter' and '\makeatother'

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
heavytull
Posts: 16
Joined: Wed Feb 08, 2012 9:38 pm

Use of '\makeatletter' and '\makeatother'

Post by heavytull »

I'm using \makeatletter and \makeatother in a *.sty file for commands generated with newcommand.py, but depending the place at which it is put it can make the compilation failing with e.g. the following error:

Code: Select all

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.133 \newif\if@
                firstdetailselement\@firstdetailselementtrue
? 
when /makeatother is just above a \newif.

When it is later in the file I get the following error:
! You can't use `\spacefactor' in vertical mode.
\@->\spacefactor 
                 \@m 
l.121 \section{Skills}
There's a \renewcommand*{\section} in the file; if I put the \makeatletter just after that command definition the compilation runs without errors. But the problem is that I need it above.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Use of '\makeatletter' and '\makeatother'

Post by sommerfee »

heavytull wrote:I'm using \makeatletter and \makeatother in a .sty file
\makeatletter and \makeatother are not needed in sty files and one should not use them in sty files at all.

So I guess all your problems go away if you just omit them.
heavytull
Posts: 16
Joined: Wed Feb 08, 2012 9:38 pm

Re: Use of '\makeatletter' and '\makeatother'

Post by heavytull »

Right, it works without these commands, thanks.
Post Reply