Julian, 

Thanks for the explanation.



________________________________
 From: Julien Rioux <jri...@lyx.org>
To: lyx-users@lists.lyx.org 
Sent: Tuesday, May 21, 2013 1:46:54 PM
Subject: Re: LyX ; look up `weird error' in the index to The TeXbook.)
 

On 28/03/2013 1:58 PM, John Kane wrote:
> LyX 2.0.5.1 Ubuntu 12.10
>
> I am trying to import and run a LateX file in LyX. The problem arises
> when I have a figure with subfigures.  A single figure processes with no
> problem.
>
> The file is fine in LaTeX but chokes in Lyx. I have seen a few
> references to the problem on the internet but I have not seen any
> solution that makes sense to me. The closest thing seems to be
> http://tex.stackexchange.com/questions/19946/missing-number-treated-as-zero
> but since it is referring to a LaTeX problem not a LyX problem it does
> not help.
>
> The original file produces 14 pages of pdf output with 12 figures both
> single and multiple layouts with no problems and so I thought I'd see
> how well it imports into LyX
>
> I have attached a stripped-down .tex file and two png files that I am
> using as a test case. I imported the .tex file into LyX using File >
> Import > Latex(plain)...
>
> The error message is :
> Missing number, treated as zero.
> Illegal unit of measure (pt inserted).
> Missing number, treated as zero.
> Illegal unit of measure (pt inserted).
> Missing number, treated as zero.
> Illegal unit of measure (pt inserted).
> Missing number, treated as zero.
> Illegal unit of measure (pt inserted).
> Missing number, treated as zero.
> Missing number, treated as zero.
> Illegal unit of measure (pt inserted).
>
> Description:
> \centering \begin{subfigure}{[}
> b{]}{0.5\textwidth} \centering
> A number should have been here; I inserted `0'.
> (If you can't figure out why I needed to see a number,
> look up `weird error' in the index to The TeXbook.)
>
> When I look at the LaTeX Preamble in LyX I get:
> \usepackage[hang,flushmargin]{footmisc}\usepackage[english]{babel}
> \usepackage[font={small,it}]{caption}\usepackage{subcaption}\author{John
> the Toucanite}
> \title{The Scholar}
>
> My LaTeX preamble is
> \documentclass[12pt]{article}
> \usepackage[margin = 4.0 cm]{geometry}
> \usepackage[hang,flushmargin]{footmisc}
> \usepackage[utf8]{inputenc}
> \usepackage[T1]{fontenc}
> \usepackage[english]{babel}
> \usepackage{graphicx}
> \usepackage[font={small,it}]{caption}
> \usepackage{subcaption}
> \author{John the Toucanite}
> \title{The Scholar}
> \date{}
>
> I tried pasting the LaTeX preamble into LyX and removed
> \documentclass[12pt]{article}
> \usepackage[margin = 4.0 cm]{geometry}
> since they were giving me conflicts.
>
> I still get the same error.
>
>
>
>
>

Indeed, \begin{subfigure}[h]{0.5\textwidth} isn't parsed correctly by 
tex2lyx: It is put into ERT except that [h] ends up outside of ERT. On 
LaTeX output, LyX tries to protect the square brackets by outputting 
{[}h{]}, but this is incorrect LaTeX.

Just checked and this bug is also in the development version LyX 2.1

-- 
Julien

Reply via email to