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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
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