0

I have tried quite many methods of getting two figures to compile side by side. Most of these method end up giving this error

Emergency stop subcaption.sty 66

Which shows this line in the file subcaption.sty

\subcaption@CheckCompatibility

I have tried most of the methods provided in these links:

Two figures side by side

LaTeX figures side by side

Putting two figures side by side

Side-by-side images in LaTeX

I have tried changing \usepackage{subfigure} with \usepackage{subfig} I have tried to change the options provided in front of subfigure.

The code for the two figures as it is now:

\begin{figure}[ht]
    \centering
    \parabox{4cm}{
    \includegraphics[width=4cm]{{ example−image−a}}
    \caption{Fyrir}
    \qquad
    \begin{minipage}{4cm}
      \includegraphics[width=4cm]{ example−image−b}
      \caption{Eftir}
    \end{minipage}
    \caption{Mismunur í afhendingagetu milli 2019 og 2023 \label{fig:afhendingageta}}
     \end{figure}

All of the packages (current):

\usepackage[utf8]{inputenc}
\usepackage[icelandic]{babel}
\usepackage{t1enc}
\usepackage{graphicx,booktabs}
\usepackage[intoc]{nomencl}
\usepackage{enumerate,color}
\usepackage{url}
\usepackage[pdfborder={0 0 0}]{hyperref}
\BeforeTOCHead[toc]{\cleardoublepage\pdfbookmark{\contentsname}{toc}} % Add Table of Contents to PDF "bookmark" table of contents
\usepackage{appendix}
\usepackage{eso-pic}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{longtable}
\usepackage[sf,normalsize]{subfigure}
\usepackage[format=plain,labelformat=simple,labelsep=colon]{caption}
\usepackage{placeins}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{adjustbox}
\usepackage{subcaption}
\usepackage{subfig}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{external}
% Packages used for title page layout
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{positioning}

My LaTeX document is quite massive, so if you want a minimal working document, I'll paste it into pastebin (or similar) and share the link here. If there is a spelling mistake in my code, I am not seeing it.

I am pretty sure all of me system is up to date (on a rolling release Linux).

  • 1
    Please make a single MWE not sniplets like this and please use images others have access to for example those that come with the mwe package https://ctan.org/pkg/mwe?lang=en. In short make a self contained minimal example others can copy and test as is. Then it is a lot easier to test your code and offer help. – daleif Mar 23 '23 at 12:39
  • Often in the process of making the example or reducing it to be minimal you will find the source of the problem. – daleif Mar 23 '23 at 12:39
  • Working on figuring out how to install the package (and then how to use it). – Ólafur Víðir Guðbjargarson Mar 23 '23 at 12:43
  • Is this the change that needed to happen ( example−image−a and example−image−b)? – Ólafur Víðir Guðbjargarson Mar 23 '23 at 12:53
  • Yes and then make it a single example. Here there is no document class (in examples you should generally use a standard class) and there is no \begin/end{document} – daleif Mar 23 '23 at 12:55
  • There are stupid many renewcommand in the document. I think it would be better to throw it on pastebin and share it like that. – Ólafur Víðir Guðbjargarson Mar 23 '23 at 12:57
  • BTW looking at your preamble, it is a big mess. subfigure, subfig, subcaption all at the same time. Probably only use the latter. Replace \usepackage{t1enc} with \usepackage[T1]{fontenc}. – daleif Mar 23 '23 at 12:57
  • 1
    No, links rot over time and your question will become unusable for others. This is why we ask for a minimal example, not your whole document. But fix the packages I mentioned a minute ago – daleif Mar 23 '23 at 12:58
  • Additionally, with a few exceptions, hyperref should be the last package to be loaded (as it has to adjust itself to other packages) – daleif Mar 23 '23 at 12:59
  • Well, this came standard from my univercity. I have cleaned some, but being a bit new to latex. So remove subfigure, subfig and subcaption and keep tlenc and T1 ? – Ólafur Víðir Guðbjargarson Mar 23 '23 at 13:00
  • Note that your code example does not even use any subfigures which should be an indicator that something else is going on (aka your messy preamble). – daleif Mar 23 '23 at 13:00
  • I did try bebin{subfigure} and I got an error, can't remember now it was the same or not. – Ólafur Víðir Guðbjargarson Mar 23 '23 at 13:02
  • 1
    Did that entire mess come from your University? Shame on them. You should only use the package y6ou actually need. Also a good idea to add a small comment above each package with a small note as to what they do. Then it is easier to determine if this is something you need – daleif Mar 23 '23 at 13:02
  • I probably added subfig without noticing the subfigure package – Ólafur Víðir Guðbjargarson Mar 23 '23 at 13:05
  • Note that the name you use for the images are not ascii the should be - – daleif Mar 23 '23 at 13:06
  • I can't see the difference. between these :( And I am not sure if I use ascii at all... – Ólafur Víðir Guðbjargarson Mar 23 '23 at 13:07
  • Are you on a Mac? It is called example-image-a not example–image–a, the former is using ascii hyphen the latter is using (or similar) a unicode char for an en-dash. – daleif Mar 23 '23 at 13:10
  • I am on Arch Linux, and the dash is the only option I have for my keyboard language. Note though, I copied the names example-image-a from the mwe document found here https://ctan.uib.no/macros/latex/contrib/mwe/mwe.pdf – Ólafur Víðir Guðbjargarson Mar 23 '23 at 13:17
  • It might be your editor that converts it. I've seen some editors do this on Mac. Arch? Oh boy... Their LaTeX version can be a bit of a mess. – daleif Mar 23 '23 at 13:19
  • In any case, your parbox has no closing brace, You should probably add one after the first \caption. – John Kormylo Mar 23 '23 at 13:46

1 Answers1

1

Just FWI this compiles

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[icelandic]{babel}
% \usepackage{t1enc}
\usepackage[T1]{fontenc}
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx,booktabs}
\usepackage[intoc]{nomencl}
\usepackage{enumerate,color}
\usepackage{url}
\usepackage{appendix}
\usepackage{eso-pic}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{longtable}
%\usepackage[sf,normalsize]{subfigure}
\usepackage[format=plain,labelformat=simple,labelsep=colon]{caption}
\usepackage{placeins}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{adjustbox}
\usepackage{subcaption}
%\usepackage{subfig}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{external}
% Packages used for title page layout
\usepackage{tikz}
\usetikzlibrary{positioning}

\usepackage[pdfborder={0 0 0}]{hyperref} \BeforeTOCHead[toc]{\cleardoublepage\pdfbookmark{\contentsname}{toc}} % Add Table of Contents to PDF "bookmark" table of contents

\begin{document}

\begin{figure}[ht] \centering \parbox{4cm}{ \includegraphics[width=4cm]{example-image-a}} \caption{Fyrir} \qquad \begin{minipage}{4cm} \includegraphics[width=4cm]{example-image-b} \caption{Eftir} \end{minipage} \caption{Mismunur í afhendingagetu milli 2019 og 2023 \label{fig:afhendingageta}} \end{figure}

\end{document}

Comments

  • use \usepackage[T1]{fontenc} instead of t1enc
  • use enumitem over enumerate
  • use xcolor over color
  • I'd probably use subcaption instead of the others
  • load hyperref last
  • There were several spelling errors in the code provided.
  • Load only packages that you actually need.
  • It is good advise to write a small note above each package explaining why it is used. Then if the doc is given to someone else to use as a template they can decide if they need it.
daleif
  • 54,450