0

Whenever I want to insert an image or a table, there are the same errors:

\begin{figure} or \begin{table} -> Undefined control sequence. \end{figure} or \end{table} -> \begin{document} ended by \end{figure}. Extra }, or forgotten \endgroup. Extra \endgroup. Too many }'s.

Somebody said there might be a package that's too old, or doesn't work with others, but I don't know where to start.

\documentclass[twoside,a4paper,11pt,openright]{report}

\usepackage[utf8]{inputenc} % Einstellung der Eingabekodierung
\usepackage[ngerman]{babel} % Deutsche Trennmuster

\usepackage{newtxtext, newtxmath} % Schriftart Palatino & passende Mathe-Schrift
\usepackage[T1]{fontenc}    % Einstellung Schriftkodierung
\usepackage{amsmath}        % Mathematik-Erweiterungen
\usepackage{microtype}      % Verbesserte Mikrotypographie
\usepackage{csquotes}       % Kontextabhängige Anführungszeichen
\usepackage{calc}       % Berechnung von TeX-Maßen
\usepackage[%
  inner=25mm,%
  outer=35mm,%
  top=20mm,%
  bottom=30mm,%
]{geometry}         % Anpassung Satzspiegel
\usepackage{parskip}        % Kein Absatzeinzug
\usepackage{emptypage}      % Keine Seitenzahlen auf Leerzeiten
\usepackage{array}      % Tabellen-Erweiterung
\usepackage[pdftex]{graphicx}       % Einbindung von Grafiken
\usepackage{float}      % Anpassung von Gleitumgebungen
\usepackage{fancyhdr}       % Anpassung von Kopf- und Fußzeilen
\selectlanguage{german} % Einstellung der Sprache

\usepackage{textcomp}
\usepackage{xcolor}     % Farben
\usepackage{subcaption} % Unternummerierung für Abbildungen
\usepackage{listings}       % Quelltextauszüge
\usepackage{listingsutf8}
\usepackage{siunitx}        % Physikalische Einheiten
\usepackage{chemformula} % chemische Symbole, Reaktionsgleichungen
\usepackage[nohyperlinks]{acronym} % Abkürzungen
\usepackage{tocloft} % eigene "list of things"
\usepackage{caption}

\usepackage[colorlinks=false, pdfborder={0 0 0}]{hyperref}

\floatplacement{figure}{htb}
\floatplacement{table}{htb} % Anpassungen für Gleitumgebungen

\newenvironment{tucsimplesection}[2][\bigskipamount]
{
  \par\centerline{\textbf{\Large #2}}\par
  \vspace*{#1}
}
{} % Einfache Überschriften für Aufgabenstellung usw.

\makeatletter
\let\@xfloat=\latex@xfloat
\makeatother % Erweiterter Zeilenabstand in Gleitumgebungen, Fußnoten und Minpages


\begin{document}

% Römische Seitenzahlen für den Vorspann.
\pagenumbering{roman}

%\input{inhalt/titlepage}

% Inhaltsverzeichnis
%\tableofcontents

\pagenumbering{arabic}

\begin{figure}[h] % error: Undefined control sequence.
    \centering
    \includegraphics[width=0.8\textwidth]{bilder/inside_battery.jpg}
    \caption{Reaktionen in der Batterie}
    \label{fig:inside_battery}
\end{figure} % error:  \begin{document} ended by \end{figure}. Extra }, or forgotten \endgroup. Extra \endgroup. Too many }'s.

% Tabelle mit Zeiten etc.
\begin{table} [h] % error: Undefined control sequence.
    \captionsetup{labelformat=empty}
    \centering
    \caption{Messablauf}
    \label{tab:Messablauf}
    \begin{tabular}{p{2.5cm} p{2.5cm} p{2.5cm} p{5cm} p{2.5cm}}
        \hline
        $t_{on} / s$ & $t_{off}$ / s & $\dfrac{t_{on}}{t_{off}}$ & $R_{3}$ (Entladewiderstand) / \si\ohm & max. I / A \\ [1ex]
        \hline
        \hline
        5 & 5 & 1 : 1 &  &  \\
        \hline
        50 & 50 & 1 : 1 &  &  \\
        \hline
    \end{tabular}
\end{table} % error: \begin{document} ended by \end{table}. Extra }, or forgotten \endgroup. Extra \endgroup. Too many }'s.

\end{document}
3
  • 1
    Welcome to Tex.SX! Unfortunately your "minimal" working example is anything but. Please try to reduce it as much as possible, making it much easier for us to help you. Start by removing unnecessary packages, comments, etc. until you have only a few lines left that still compile, and clearly show your problem.
    – Ingmar
    Commented Apr 24, 2023 at 13:41
  • 4
    I took a wild guess, and it seems that \let\@xfloat=\latex@xfloat is your problem. What's your intent with that line?
    – Teepeemm
    Commented Apr 24, 2023 at 13:42
  • 1
    are you sure you want \floatplacement{figure}{htb} ? that removes p so makes it very likely that all figures go to the end of the document. Commented Apr 24, 2023 at 13:51

1 Answer 1

4

You did not show the error which is

! Undefined control sequence.
\@xfloat #1[#2]->\caption@ORI@xfloat 
                                     {#1}[#2]\caption@settype {#1}\caption@s...
l.66 \begin{figure}[h]
                       % error: Undefined control sequence.
? 

so the undefined command is \caption@ORI@xfloat

You have loaded the caption package then broken its internal workings by doing


\makeatletter
\let\@xfloat=\latex@xfloat
\makeatother % Erweiterter Zeilenabstand in Gleitumgebungen, Fußnoten und Minpages

you should delete that.

In general only have code in the preamble that you know you are using. It seems highly unlikely you are using all these packages, loading so many will lead to conflicts such as

Package tocloft Warning: \@starttoc has already been redefined; tocloft bailing
 out. on input line 1156.

You must log in to answer this question.

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