LyXCompilation fails with an equation array and a subfloat

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
samfarrell
Posts: 2
Joined: Thu Dec 06, 2012 7:33 pm

Compilation fails with an equation array and a subfloat

Post by samfarrell »

Hi, I'm trying to insert two sets of Math formulas side by side, so I'm using equation arrays inside subfloats - but I can't get the document to compile. Any advice would be appreciated.

This is my first post to the board; I think I've stuck to the board rules, but please let me know if I've missed anything out!

I've narrowed the problem down to the following; the errors are returned when an eqnarray or AMS align block is placed inside a subfloat. I've tried it in a single float which works fine, as does using an inline formula in a subfloat. Using a displayed formula inside a subfloat returns a different error (LaTeX Error: Bad math environment delimiter).

A minimal example, generated by the graphical editor:

Code: Select all

%% LyX 2.0.5 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}

\makeatletter
\@ifundefined{showcaptionsetup}{}{%
 \PassOptionsToPackage{caption=false}{subfig}}
\usepackage{subfig}
\makeatother

\begin{document}
\begin{figure}
\subfloat[foo]{
\begin{eqnarray*}
A & = & B
\end{eqnarray*}
}

\caption{goo}
\end{figure}
\end{document}
Here's the log:

Code: Select all

This is pdfTeX, Version 3.1415926-2.4-1.40.13 (MiKTeX 2.9) (preloaded format=pdflatex 2012.12.6)  6 DEC 2012 18:34
entering extended mode
**newfile3.tex
(C:\Users\Julia\AppData\Local\Temp\lyx_tmpdir.Hp5960\lyx_tmpbuf6\newfile3.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, afrikaans, ancientgreek, ar
abic, armenian, assamese, basque, bengali, bokmal, bulgarian, catalan, coptic, 
croatian, czech, danish, dutch, esperanto, estonian, farsi, finnish, french, ga
lician, german, german-x-2012-05-30, greek, gujarati, hindi, hungarian, iceland
ic, indonesian, interlingua, irish, italian, kannada, kurmanji, latin, latvian,
 lithuanian, malayalam, marathi, mongolian, mongolianlmc, monogreek, ngerman, n
german-x-2012-05-30, nynorsk, oriya, panjabi, pinyin, polish, portuguese, roman
ian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, swissgerm
an, tamil, telugu, turkish, turkmen, ukenglish, ukrainian, uppersorbian, usengl
ishmax, welsh, loaded.

("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\size10.clo"
File: size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
) ("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\fontenc.sty"
Package: fontenc 2005/09/27 v1.99g Standard LaTeX package
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\t1enc.def"
File: t1enc.def 2005/09/27 v1.99g Standard LaTeX file
LaTeX Font Info:    Redeclaring font encoding T1 on input line 43.
)) ("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\inputenc.sty"
Package: inputenc 2008/03/30 v1.1d Input encoding file
\inpenc@prehook=\toks14
\inpenc@posthook=\toks15
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\latin9.def"
File: latin9.def 2008/03/30 v1.1d Input encoding file
)) (C:\Users\Julia\AppData\Roaming\MiKTeX\2.9\tex\latex\subfig\subfig.sty
Package: subfig 2005/06/28 ver: 1.3 subfig package
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\graphics\keyval.sty"
Package: keyval 1999/03/16 v1.13 key=value parser (DPC)
\KV@toks@=\toks16
) (C:\Users\Julia\AppData\Roaming\MiKTeX\2.9\tex\latex\caption\caption.sty
Package: caption 2012/02/19 v3.2f Customizing captions (AR)
(C:\Users\Julia\AppData\Roaming\MiKTeX\2.9\tex\latex\caption\caption3.sty
Package: caption3 2012/01/12 v1.4b caption3 kernel (AR)
\captionmargin=\dimen103
\captionmargin@=\dimen104
\captionwidth=\dimen105
\caption@indent=\dimen106
\caption@parindent=\dimen107
\caption@hangindent=\dimen108
)
\c@ContinuedFloat=\count87
)
\c@KVtest=\count88
\sf@farskip=\skip43
\sf@captopadj=\dimen109
\sf@capskip=\skip44
\sf@nearskip=\skip45
\c@subfigure=\count89
\c@subfigure@save=\count90
\c@lofdepth=\count91
\c@subtable=\count92
\c@subtable@save=\count93
\c@lotdepth=\count94
\sf@top=\skip46
\sf@bottom=\skip47
)
No file newfile3.aux.
LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 15.
LaTeX Font Info:    ... okay on input line 15.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 15.
LaTeX Font Info:    ... okay on input line 15.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 15.
LaTeX Font Info:    ... okay on input line 15.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 15.
LaTeX Font Info:    ... okay on input line 15.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 15.
LaTeX Font Info:    ... okay on input line 15.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 15.
LaTeX Font Info:    ... okay on input line 15.
Package caption Info: Begin \AtBeginDocument code.
Package caption Info: subfig package v1.3 is loaded.
Package caption Info: End \AtBeginDocument code.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <7> on input line 23.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <5> on input line 23.
! Missing \endgroup inserted.
<inserted text> 
                \endgroup 
l.23 }
      
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.

! Missing } inserted.
<inserted text> 
                }
l.23 }
      
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.


Overfull \hbox (43.36462pt too wide) in alignment at lines 23--23
[][][] []
 []


! LaTeX Error: \begin{figure} on input line 16 ended by \end{eqnarray*}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.23 }
      
Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.

! Missing $ inserted.
<inserted text> 
                $
l.23 }
      
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.

! Display math should end with $$.
<to be read again> 
                   \endgroup 
l.23 }
      
The `$' that I just saw supposedly matches a previous `$$'.
So I shall assume that you typed `$$' both times.


Overfull \hbox (7.77588pt too wide) in paragraph at lines 23--23
[]\T1/cmr/m/n/10 a:
 []


Overfull \hbox (13.33008pt too wide) in paragraph at lines 23--23
|\T1/cmr/m/n/10 foo| 
 []


! Package caption Error: \caption outside float.

See the caption package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.25 \caption
             {goo}
If you do not understand this error, please take a closer look
at the documentation of the `caption' package, especially the
section about errors.
Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

! Too many }'s.
\@endfloatbox ...pagefalse \outer@nobreak \egroup 
                                                  \color@endbox 
l.26 \end{figure}
                 
You've closed more groups than you opened.
Such booboos are generally harmless, so keep going.


! LaTeX Error: \begin{document} ended by \end{figure}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.26 \end{figure}
                 
Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.

! Extra \endgroup.
<recently read> \endgroup 
                          
l.26 \end{figure}
                 
Things are pretty mixed up, but I think the worst is over.

[1

{C:/Users/Julia/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] (C:\Users\J
ulia\AppData\Local\Temp\lyx_tmpdir.Hp5960\lyx_tmpbuf6\newfile3.aux) ) 
Here is how much of TeX's memory you used:
 1630 strings out of 493921
 25772 string characters out of 3144876
 80402 words of memory out of 3000000
 4983 multiletter control sequences out of 15000+200000
 4403 words of font info for 15 fonts, out of 3000000 for 9000
 841 hyphenation exceptions out of 8191
 44i,7n,46p,206b,259s stack positions out of 5000i,500n,10000p,200000b,50000s
 <C:\Users
\Julia\AppData\Local\MiKTeX\2.9\fonts\pk\ljfour\jknappen\ec\dpi600\ecrm1000.pk>
Output written on newfile3.pdf (1 page, 2939 bytes).
PDF statistics:
 15 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)
Thanks!
Attachments
lyx errors.txt
(8.32 KiB) Downloaded 289 times

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

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

Compilation fails with an equation array and a subfloat

Post by Stefan Kottwitz »

Hi,

welcome to the board!

It's great that you narrowed it down and posted a minimal example, so it's easy to test and to fix, especially as it's in LaTeX code.

If something, which usually works, doesn't work in certain places, it often can be fixed by putting it into a parbox or a minipage (LyX: Insert -> Box). This works:

Code: Select all

\begin{figure}
\subfloat[foo]{\parbox{\textwidth}{
\begin{eqnarray*}
A & = & B
\end{eqnarray*}}
}
\caption{goo}
\end{figure}
However, I strongly recommend to use amsmath environments such as align instead of eqnarray, see eqnarray vs. align for reasons. Boxing it, as above, works with it as well.

Stefan
LaTeX.org admin
samfarrell
Posts: 2
Joined: Thu Dec 06, 2012 7:33 pm

Re: Compilation fails with an equation array and a subfloat

Post by samfarrell »

Great, that works fine. Thanks for the advice on that (and eqnarray vs amsmath).
Post Reply