Text Formattingsubfig package conflicting with mcode package

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
spurta
Posts: 10
Joined: Sat Oct 24, 2009 11:36 am

subfig package conflicting with mcode package

Post by spurta »

I am finishing off my research project for this year and want to include a lot of Matlab code. The mcode package does a good job of representing Matlab with all colours etc, but will not load document with subfig package.

It causes the following error message:

Code: Select all

! Undefined control sequence.
<argument> ...t@title \endgroup }\newcaptionstyle
{lsttitle}{\caption@make {...
l.72 \begin{document}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Argument of \caption@make has an extra }.
<inserted text>
\par
l.72 \begin{document}
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.
Runaway argument?
! Paragraph ended before \caption@make was complete.
<to be read again>
\par
l.72 \begin{document}
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
I really would like to use this package, I believe it fails with the listings package as well (which mcode is based on). If I remove the subfig package it then fails for the \subfloat command. Any help would be much appreciated.

Recommended reading 2024:

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

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

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

subfig package conflicting with mcode package

Post by localghost »

There are two things that would get us closer to a solution and which you should keep in mind for future requests.
  • With the mcode package you are using one that is not available on CTAN. So you have to attach it or give a link where to find it (see Board Rules).
  • Reduce the problem to a minimal working example (MWE). This way we not only can see what is your problem but also its origin.
In the meantime I found a source for the mcode package so that the first point can be neglected [1]. You should fetch the second point later in your next post.

I took a look at the package code. It loads the listings package subsequently. Make sure that you have the latest version and upgrade if necessary. If you are also using the caption package, do the same. The best is to keep your whole LaTeX system up-to-date. Modern distributions provide a more or less comfortable package manager.

[1] MATLAB Central - File Detail - M-code LaTeX Package


Best regards and welcome to the board
Thorsten¹
spurta
Posts: 10
Joined: Sat Oct 24, 2009 11:36 am

subfig package conflicting with mcode package

Post by spurta »

Thanks Thorsten, Here is the mwe.

Code: Select all

\documentclass[oneside,11pt]{report} 
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{graphics,appendix}
\usepackage{placeins}
\usepackage{float}
\usepackage{setspace}
\usepackage[square,comma,sort&compress]{natbib}
\usepackage{indentfirst}
\usepackage{url}
\usepackage{mdwlist}
\usepackage{subfig}
\usepackage{color}
\usepackage{mcode}

\begin{document}

Try running this with subfig in and see the error.  This is the error I am having.  If the subfig package is removed I cannot use subfloat command which is used numerous times in the report.

\begin{figure}[H]
\begin{center}
\subfloat[subfloat description]{\includegraphics[scale=0.8, bb = 0 0 200 206]{xxxx.png}}
\hspace{10mm}
\subfloat[subfloat description]{\includegraphics[scale=0.8, bb = 0 0 200 206]{xxxx.png}}
 \vspace{-3mm}\caption{\small{caption}} \label{fig:key}
\end{center}
\end{figure}
\FloatBarrier

\end{document}
Thanks in advance.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

subfig package conflicting with mcode package

Post by localghost »

Your example is not a MWE because it contains packages that are irrelevant to the problem and it tries to include graphics files that are not present to me.

Your example works fine for me in nonstop mode except some warnings concerning the graphics files. You should check your log file for that, too. For comparison of package versions see my list of used files. It is generated by the \listfiles command (usually the very first line in the code) and can be found in the log file.

Code: Select all

 *File List*
  report.cls    2005/09/16 v1.4f Standard LaTeX document class
  size11.clo    2005/09/16 v1.4f Standard LaTeX file (size option)
inputenc.sty    2006/05/05 v1.1b Input encoding file
  latin1.def    2006/05/05 v1.1b Input encoding file
 amsmath.sty    2000/07/18 v2.13 AMS math features
 amstext.sty    2000/06/29 v2.01
  amsgen.sty    1999/11/30 v2.0
  amsbsy.sty    1999/11/29 v1.2d
  amsopn.sty    1999/12/14 v2.01 operator names
amsfonts.sty    2001/10/25 v2.2f
 amssymb.sty    2002/01/22 v2.2d
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
graphics.sty    2006/02/20 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
  pdftex.def    2008/07/16 v0.04k Graphics/color for pdfTeX
appendix.sty    2002/08/06 v1.2 extra appendix facilities
placeins.sty    2005/04/18  v 2.2
   float.sty    2001/11/08 v1.3d Float enhancements (AL)
setspace.sty    2000/12/01 6.7 Contributed and Supported LaTeX2e package
  natbib.sty    2007/10/30 8.1 (PWD)
indentfirst.sty    1995/11/23 v1.03 Indent first paragraph (DPC)
     url.sty    2006/04/12  ver 3.3  Verb mode for urls, etc.
 mdwlist.sty    1996/05/02 1.1 Various list-related things
  subfig.sty    2005/06/28 ver: 1.3 subfig package
 caption.sty    2008/04/01 v3.1h Customizing captions (AR)
caption3.sty    2008/03/20 v3.1h caption3 kernel (AR)
   color.sty    2005/11/14 v1.0j Standard LaTeX Color (DPC)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
   mcode.sty    2008/08/28 1.3
listings.sty    2007/02/22 1.4 (Carsten Heinz)
 lstmisc.sty    2007/02/22 1.4 (Carsten Heinz)
listings.cfg    2007/02/22 1.4 listings configuration
textcomp.sty    2005/09/27 v1.99g Standard LaTeX package
  ts1enc.def    2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
  ts1cmr.fd    1999/05/25 v2.5h Standard LaTeX font definitions
supp-pdf.tex
 ***********
Note that these packages or not present in their current version on my Linux system which still works with TeX Live 2008. But they seem to be new enough to make your example work. The result is attached.

Just another hint for notification. The caption package contains another small package which is called subcaption. Regarding the fact that subfig isn't maintained anymore this might be the better alternative.
Attachments
mcode-prblm.pdf
The result produced by the provided example code.
(18.42 KiB) Downloaded 284 times
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

subfig package conflicting with mcode package

Post by sommerfee »

spurta wrote:

Code: Select all

! Undefined control sequence.
<argument> ...t@title \endgroup }\newcaptionstyle
{lsttitle}{\caption@make {...
l.72 \begin{document}[/quote]

It seems you are using an at least 6 years old version of the listings package which is incompatible to the subfig package (and the actual version of the caption package).

So if you update your listings package the error should go away.

HTH,
Axel
spurta
Posts: 10
Joined: Sat Oct 24, 2009 11:36 am

Re: subfig package conflicting with mcode package

Post by spurta »

Thanks Guys,

I have downloaded an upgraded version of subfig, listings and put in tex/latex directory but I dont know how to tell LaTex that the version is different? Every time I check the log file like Thorsten mentioned it still has the old version number.

Thanks, Leon.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: subfig package conflicting with mcode package

Post by localghost »

Use the package manager of your LaTeX distribution to install packages.
Post Reply