0

I'm new to LaTex and writing my first paper. For some reason a lot of my sections and subsections have the following error:

enter image description here

My code is quite long so I'm not sure which lines to share other than this one, but from this SO question I believe that the document type is important. Mine is:

\documentclass{article}

And the rest of the packages are

\usepackage[utf8]{inputenc}
\usepackage{graphicx}
% \usepackage[section]{placeins}
% \usepackage{placeins}
\usepackage{float}
\let\Oldsection\section
\renewcommand{\section}{\FloatBarrier\Oldsection}
\let\Oldsubsection\subsection
\renewcommand{\subsection}{\FloatBarrier\Oldsubsection}
\let\Oldsubsubsection\subsubsection
\renewcommand{\subsubsection}{\FloatBarrier\Oldsubsubsection}
\usepackage{caption}
\usepackage{subcaption}
% \usepackage[LGRgreek]{mathastext}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{diagbox}
\usepackage{rotating}
% \documentclass{article}
\usepackage{geometry}
\usepackage[skip=1ex]{caption}
\usepackage{amsmath}

\usepackage[hidelinks,colorlinks=true,linkcolor=blue,citecolor=blue]{hyperref}
\usepackage[backend=biber,style=numeric,sorting=none]{biblatex}
\addbibresource{mybib.bib}
\usepackage {hyperref}

From one of the comments in the above SO question they mentioned "The article class doesn't define \sectionfont, so you must provide a definition for it". But I'm not sure what it means or how to define a font, as I'm new.

8

1 Answer 1

4

Posting as a complete test file:

\documentclass{article}


\usepackage[utf8]{inputenc}
\usepackage{graphicx}
% \usepackage[section]{placeins}
% \usepackage{placeins}
\usepackage{float}
\let\Oldsection\section
\renewcommand{\section}{\FloatBarrier\Oldsection}
\let\Oldsubsection\subsection
\renewcommand{\subsection}{\FloatBarrier\Oldsubsection}
\let\Oldsubsubsection\subsubsection
\renewcommand{\subsubsection}{\FloatBarrier\Oldsubsubsection}
\usepackage{caption}
\usepackage{subcaption}
% \usepackage[LGRgreek]{mathastext}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{diagbox}
\usepackage{rotating}
% \documentclass{article}
\usepackage{geometry}
\usepackage[skip=1ex]{caption}
\usepackage{amsmath}

\usepackage[hidelinks,colorlinks=true,linkcolor=blue,citecolor=blue]{hyperref}
\usepackage[backend=biber,style=numeric,sorting=none]{biblatex}
\addbibresource{mybib.bib}
\usepackage {hyperref}

\begin{document}

\section{zzz}
zzz
\end{document}

You will see in the log the error is

! Undefined control sequence.
\section ->\FloatBarrier 
                         \Oldsection 
l.35 \section
             {zzz}
? 

Showing that the undefined command is \FloatBarrier which you have not defined.

It is defined by the placeins package which is not loaded, but even if that package is used you should not redefine \section in this way. Simply use the section option, as is also shown commented out in your posting.

So the basic fix is to delete

\let\Oldsection\section
\renewcommand{\section}{\FloatBarrier\Oldsection}
\let\Oldsubsection\subsection
\renewcommand{\subsection}{\FloatBarrier\Oldsubsection}
\let\Oldsubsubsection\subsubsection
\renewcommand{\subsubsection}{\FloatBarrier\Oldsubsubsection}

The example then runs without error.

You should also delete

\usepackage[utf8]{inputenc}

unless you have an old latex

and delete

\usepackage[skip=1ex]{caption}

and

\usepackage {hyperref}

as you have already loaded those packages.

0

You must log in to answer this question.

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