Graphics, Figures & TablesProblem with subfigure in the memoir class

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

Problem with subfigure in the memoir class

Post by Cham »

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.

Code: Select all

\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 ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Problem with subfigure in the memoir class

Post by Cham »

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 ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10311
Joined: Mon Mar 10, 2008 9:44 pm

Problem with subfigure in the memoir class

Post by Stefan Kottwitz »

The best way is not using memoir... :roll:

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
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Problem with subfigure in the memoir class

Post by Cham »

Stefan Kottwitz wrote:The best way is not using memoir... :roll:

...
By the way, subfigure is obsolete and replaced by subfig by the same author
Argh, another pesky class like revtex4 and revtex4-1 ! :x

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 ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10311
Joined: Mon Mar 10, 2008 9:44 pm

Problem with subfigure in the memoir class

Post by Stefan Kottwitz »

Possibly... better take a quick look into the subfig manual, I don't use it often. I prefer subcaption. ;-)

Stefan
LaTeX.org admin
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Problem with subfigure in the memoir class

Post by Johannes_B »

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.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Problem with subfigure in the memoir class

Post by Cham »

Thanks Johannes. This brings me a question that I asked in the classes thread :

http://latex.org/forum/viewtopic.php?f= ... 81#p103481
Post Reply