GeneralWhat's wrong with revtex4-1 and the caption package ?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What's wrong with revtex4-1 and the caption package ?

Post by Cham »

Yet another problem with my revtex4 document. My document isn't compiling, because of the caption package. Yet, I need to change the revtex4-1 figures caption.

Here's a MWE showing the problem :

Code: Select all

\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[10pt,letterpaper,nofootinbib,notitlepage,tightenlines]{revtex4-1}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}

\usepackage[caption=false]{subfig}
\captionsetup{margin=1cm,format=hang,font=small,format=plain,labelfont={bf,up},textfont={it}}
\captionsetup[subfigure]{margin=0cm,font=small,format=plain,labelfont={bf,up},textfont={up}}

\usepackage{graphicx}
\usepackage{here}

\usepackage[font=small,format=plain,labelfont=bf,textfont=up]{caption}
\DeclareCaptionLabelSeparator{frenchsep}{ : }
\captionsetup{labelsep=frenchsep}

\begin{document}

\section{Title}

Bla bla bla :
\bigskip

	\begin{figure}[H]
	\centering
		\includegraphics[height=7cm]{figure.pdf}
		\caption{Some text.}
	\end{figure}

Bla bla

\end{document}
What should I do ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

What's wrong with revtex4-1 and the caption package ?

Post by Stefan Kottwitz »

What is the issue? Is there any error message? That MWE runs for me.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What's wrong with revtex4-1 and the caption package ?

Post by Cham »

Stefan,

this code doesn't compile for me. I get this error message :
Package caption Warning: Unsupported document class (or package) detected,
(caption) usage of the caption package is not recommended.
See the caption package documentation for explanation.
and this :
Error: Command \caption@ContinuedFloat already defined.
Or name \end... illegal, see p.192 of the manual.
The caption package is apparently the culprit (with my pdfLateX 2015).
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What's wrong with revtex4-1 and the caption package ?

Post by Cham »

Apparently, the caption package is uncompatible with revtex4-1.

Well, I just want the revtex4-1 document to use a bold "Figure :", for French text, instead of non-bold Lower capitals. Nothing fancy.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What's wrong with revtex4-1 and the caption package ?

Post by Cham »

Ah ! I think I got it right ! Do you confirm the modification below is all legit ?

Remove all the caption package declaration and use this instead :

Code: Select all

\usepackage[]{subfig}
\captionsetup[subfigure]{margin=0cm,font=small,format=plain,labelfont={bf,up},textfont={up}}
\captionsetup[figure]{margin=1cm,font=small,format=plain,labelfont={bf,up},textfont={up}}
\DeclareCaptionLabelSeparator{frenchsep}{ : }
\captionsetup{labelsep=frenchsep}
Full compilable modified MWE code :

Code: Select all

\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[10pt,letterpaper,nofootinbib,notitlepage,tightenlines]{revtex4-1}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
 
\usepackage[]{subfig}
\captionsetup[subfigure]{margin=0cm,font=small,format=plain,labelfont={bf,up},textfont={up}}
\captionsetup[figure]{margin=1cm,font=small,format=plain,labelfont={bf,up},textfont={up}}
\DeclareCaptionLabelSeparator{frenchsep}{ : }
\captionsetup{labelsep=frenchsep}
 
\usepackage{graphicx}
\usepackage{here}
  
\begin{document}
 
\section{Title}
 
Bla bla bla :
\bigskip
 
	\begin{figure}[H]
	\centering
		\includegraphics[height=7cm]{figure.pdf}
		\caption{Some text.}
	\end{figure}
 
Bla bla
 
\end{document}
Is that right ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

What's wrong with revtex4-1 and the caption package ?

Post by Stefan Kottwitz »

It looks ok.

But you could also do it with a manual redefinition, without the caption package and the lines above:

Code: Select all

\makeatletter
\renewcommand*{\fnum@figure}{{\normalfont\bfseries \figurename~\thefigure}}
\renewcommand*{\@caption@fignum@sep}{\textbf{ : }}
\makeatother
A good thing with LaTeX is, that one usually can adjust things with a small redefinition. It may look a bit hackish, but if it does the job it's good enough and one knows what has been done, instead of loading a comprehensive package that may change more than desired.

Stefan
LaTeX.org admin
Post Reply