5

I am pepping up a thesis. Among others I am using a package based on Modified UDO thesis by; Jose A. Flores, November 2011. Unfortunately, I cannot find the original. One part of the package seems to redefine the float definition and I boiled the error down to the following code. I created a small style file: (killer.sty) containing:

\def\@xfloat#1[#2]{\ifhmode \@bsphack\@floatpenalty -\@Mii\else
   \@floatpenalty-\@Miii\fi\def\@captype{#1}\ifinner
      \@parmoderr\@floatpenalty\z@
   \else\@next\@currbox\@freelist{\@tempcnta\csname ftype@#1\endcsname
       \multiply\@tempcnta\@xxxii\advance\@tempcnta\sixt@@n
   \@tfor \@tempa :=#2\do
                    {\if\@tempa h\advance\@tempcnta \@ne\fi
                     \if\@tempa t\advance\@tempcnta \tw@\fi
                     \if\@tempa b\advance\@tempcnta 4\relax\fi
                     \if\@tempa p\advance\@tempcnta 8\relax\fi
     }\global\count\@currbox\@tempcnta}\@fltovf\fi
\global\setbox\@currbox\vbox\bgroup 
\def\baselinestretch{1}\@normalsize
\boxmaxdepth\z@
\hsize\columnwidth \@parboxrestore
}

Actually, I have no experience with TeX programming, but from my point of view braces and if-fi are ok. In the most simple case it compiles (pdflatex) and looks ok. If I put the color package, however, it produces following error messages:

mini.tex(16): Error: Too many }'s.
mini.tex(16): Error: LaTeX Error: \begin{document} ended by \end{figure}.
mini.tex(16): Error: Extra \endgroup.

A minimal non-working example looks like this (put your pdf figure): mini.tex

\documentclass[12pt,a4paper,twoside,openright]{report} % 
%====
\usepackage{graphicx}
\usepackage{killer}
\usepackage{color}%this works if this line is commented
%====
\begin{document}
    \begin{figure}[H]
        \centering\includegraphics[width=1\columnwidth]{your.pdf}
        \caption[]{Schematic representation}        
        \label{fig:yourFig}
    \end{figure}
\end{document}

Why is this incompatible with color. I was expecting a lot, but not that.

(MikTex 2.9 on Win7 64, SP1)

3
  • 1
    That is bizarre I had never heard of that class then someone asked about it yesterday, it uses definitions from an early version of latex2.09 so puts back your document over 25 years. Dec 3, 2014 at 17:30
  • 1
  • Truly bizarre, as these are definitely two independent incidents. Dec 4, 2014 at 9:36

1 Answer 1

2

The problem seems very similar to the one in Problems with TikZ when I change document class

The solution given there should work also for your setting:

\documentclass[12pt,a4paper,twoside,openright]{report} % 
%====
\usepackage{graphicx}

% save a copy of \@xfloat
\makeatletter\let\latex@xfloat\@xfloat\makeatother
\usepackage{killer}

% redefine \@xfloat to have the intended behavior
\usepackage{etoolbox}
\makeatletter
\let\@xfloat\latex@xfloat
\apptocmd{\@xfloat}{\linespread{1}\normalsize}{}{}
\makeatother

\usepackage{color}%this works if this line is commented
%====
\begin{document}
    \begin{figure}
        \centering\includegraphics[width=1\columnwidth]{your.pdf}
        \caption[]{Schematic representation}        
        \label{fig:yourFig}
    \end{figure}
\end{document}

(Don't use [H], you'll regret it if you do.)

If the bad code is in the class (I'll call it killer), then do

% save a copy of \@xfloat
\makeatletter\let\latex@xfloat\@xfloat\makeatother

\documentclass{killer}

\usepackage{graphicx}

% redefine \@xfloat to have the intended behavior
\usepackage{etoolbox}
\makeatletter
\let\@xfloat\latex@xfloat
\apptocmd{\@xfloat}{\linespread{1}\normalsize}{}{}
\makeatother

\usepackage{color}%this works if this line is commented

\begin{document}
    \begin{figure}
        \centering\includegraphics[width=1\columnwidth]{your.pdf}
        \caption[]{Schematic representation}        
        \label{fig:yourFig}
    \end{figure}
\end{document}
6
  • 2
    Not loading killer would be a better fix Dec 3, 2014 at 17:33
  • @DavidCarlisle Of course!
    – egreg
    Dec 3, 2014 at 17:33
  • @DavidCarlisle and @egreg. I agree, not using it, is probably the best solution. Compiling a simple example with and without, I don't see a big difference anyway. So I guess deleting this part from the UDOthesis.sty is best (tested: keeps working when removed). Do you agree? Nevertheless, I am curious what it is actually doing. Is it only changing a few distances? I also realize now that only [h] but not [H] is handled. And why is this making problems with color? Luckily @mkunkel from the other post @DavidCarlisle referred to, is not using color. (yet?) Dec 4, 2014 at 9:10
  • The workaround does the trick, although I use \documentclass{report} and \usepackage{killer}. But if I understand this correctly, this results in ignoring the \def\@xfloat part from killer completely. (see comment above) Dec 4, 2014 at 9:14
  • 1
    @mikuszefski the latex format colour support needs extra groups to keep colour local to boxes, these \colour@begingroup \color@endgroup commands are set to \relax for compatibility with latex 2.09 (ie the 1980s) but made into groups by color package. But even if the grouping is fixed, because the code is based on a 1987 latex format it removes everything added since then. [!ht] feature, the code to add H possibly doesn't match, the code to check the float fits on the page is removed... You could just remove the float part, but the rest of that file is of a similar vintage... Dec 4, 2014 at 9:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .