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

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

Problem with subfigure in the memoir class

Postby Cham » Tue Nov 28, 2017 9:27 pm

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.

  1. \RequirePackage[l2tabu,orthodox]{nag}
  2. \documentclass[11pt,twoside]{memoir}
  3. \usepackage[T1]{fontenc}
  4. \usepackage{graphicx}
  5. \usepackage{here}
  6. \usepackage{subfigure}
  7.  
  8. \begin{document}
  9.  
  10. \begin{figure}[htbp]
  11. \centering
  12. \subfigure[Description 1.]{\includegraphics[width=0.4\textwidth]{example-image-a}}
  13. \qquad
  14. \subfigure[Description 2.]{\includegraphics[width=0.4\textwidth]{example-image-b}}
  15. \caption{Some description.}
  16. \label{ }
  17. \end{figure}
  18.  
  19. \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 ?

User avatar
Cham
Posts: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Tue Nov 28, 2017 9:50 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 ?

User avatar
Stefan Kottwitz
Site Admin
Posts: 8527
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Wed Nov 29, 2017 1:19 pm

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
Site admin

User avatar
Cham
Posts: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Wed Nov 29, 2017 1:47 pm

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: 8527
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Wed Nov 29, 2017 1:53 pm

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

Stefan
Site admin

User avatar
Johannes_B
Site Moderator
Posts: 3584
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Wed Nov 29, 2017 6:41 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.

User avatar
Cham
Posts: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Wed Nov 29, 2017 8:54 pm

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

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


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 7 guests