## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Problem with subfigure in the memoir class Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
Cham
Posts: 821
Joined: Sat Apr 02, 2011 4:06 pm

### Problem with subfigure in the memoir class

I'm getting a mysterious compilation bug with the following code, when I try to build the PDF version. It renders nicely in the preview, but it don't export, why ? The same subfigure code works perfectly with all the other classes I tried.

\RequirePackage[l2tabu,orthodox]{nag}\documentclass[11pt,twoside]{memoir}\usepackage[T1]{fontenc}\usepackage{graphicx}\usepackage{here}\usepackage{subfigure} \begin{document} \begin{figure}[htbp]	\centering	\subfigure[Description 1.]{\includegraphics[width=0.4\textwidth]{example-image-a}}	\qquad	\subfigure[Description 2.]{\includegraphics[width=0.4\textwidth]{example-image-b}}	\caption{Some description.}	\label{ } \end{figure} \end{document}

Compiling gives this error message in the console :

/usr/local/texlive/2015/texmf-dist/tex/latex/subfigure/subfigure.sty:124: LaTeX Error: Command \c@lofdepth already defined.
Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.124 \newcounter{lofdepth}

So what is wrong with this simple code ?

Cham
Posts: 821
Joined: Sat Apr 02, 2011 4:06 pm
I just found that the subfigure package is uncompatible with the memoir class, because (?) this class already have subfigures options included ! Apparently, I can't copy/paste my figures from another class to the memoir version ! I need to change/adapt all the figures code for the memoir class only. This sucks !

What is the best way in fixing the code above ?

Stefan Kottwitz
Posts: 8544
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
The best way is not using memoir...

In another thread I tried to be diplomatic about memoir, when I said it's monolithic. It tries to save the user from working with a lot of packages by providing a lot of package functionality itself, so harmonizing it, ensuring compatibility. But the bad point is, such a bundle class can hardly keep up with the development of the original packages by frequently incorporating their updates. That's why I think memoir is somehow stable and ok to use, also very good for typographical ambitious users, but not for technically demanding users and for interaction with other packages.

By the way, subfigure is obsolete and replaced by subfig by the same author

Stefan

Cham
Posts: 821
Joined: Sat Apr 02, 2011 4:06 pm
Stefan Kottwitz wrote:The best way is not using memoir...

...
By the way, subfigure is obsolete and replaced by subfig by the same author

Argh, another pesky class like revtex4 and revtex4-1 !

About subfigure, how should I change my subfigures code to adapt it to the newer subfig package ?

EDIT : apparently, I just have to change \subfigure to \subfloat. is that right ?

Stefan Kottwitz
Posts: 8544
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
Possibly... better take a quick look into the subfig manual, I don't use it often. I prefer subcaption.

Stefan

Johannes_B
Site Moderator
Posts: 3588
Joined: Thu Nov 01, 2012 4:08 pm
It is a bit different. You cannot just switch classes.
LaTeX itself (or to be more precise TeX) is like LEGO, stacking blocks/bricks/boxes. The standard classes provide a limited set of extra handy bricks to play with. Many extensions have been made for the LEGO kit.

memoir and KOMA-script (bundle) provide classes that are far more complex than that basic kit from before. Imagine it as the Star Wars LEGO kit, and the Harry Potter LEGO kit. It will be o surprise, that parts from a spaceship look weird in a magical setting. Maybe the bricks won't even fit.

For a standard class geometry is the way to go to set up page size and margins. But not for memoir. Memoir has its own internal set of macros to do that. KOMA is a whole bundle and has its very own package to do the same task. Luckily, the geometry package can be used with all sets of bricks.

Package tocbibind is great for the standard classes, but it destroys functionality of both KOMA-script and memoir. Both have their own way of doing the very same task.

fancyheadr is great for the standard classes, but onnce again, memoir and KOMA-script have their own way of doing stuff.

You have to commit to one of them and stick to it.

And now to really frustrate you, most journal classes are based on that very limited and basic LEGO kit called standard. And each journal adds new bricks. Why not? There is no need to customize anything. It (the layout and fuctionality) needs to be fixed.

-----------------------

To put it another way: TeX provides everything to biuld some tools. Standard LaTeX classes provide a basic set of tools, including 7 different screw drivers. KOMA-script and memoir are like an electric more powerful screwdriver, different bits you can choose from (flat, phillips head, torx in different sizes). But if one bit is missing, you are screwed.
Journal classes (of course not all) are like a hammer fixed with gaffa tape.

EDIT: Just look here. What Stefan posted is suitable for all classes. What i suggested is only valid for that template with that class. Both KOMA and memoir have a similar, but different way of doing the same task.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Cham
Posts: 821
Joined: Sat Apr 02, 2011 4:06 pm
Thanks Johannes. This brings me a question that I asked in the classes thread :

viewtopic.php?f=4&t=30680&p=103481#p103481