Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Background

Include multiple appendixes in a book. (Using KOMA Script v2.)

Problem

I have isolated the problem and created a minimal example to demonstrate the issue:

The only difference (according to gVim's diff tool) between good.lyx and bad.lyx are the following lines:

\begin_layout Subsection
jasper.php
\end_layout

\begin_layout Standard
TODO
\end_layout

Loading good.lyx into LyX works as expected: a PDF can be created. Loading bad.lyx into LyX does not work as expected. The following error results:

Missing number, treated as zero.

\end{document}

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.)

Questions

  • Why does typing one more subsection cause an error?
  • How can the error be resolved so that any number of sections and subsections can be added to the appendix?

Thank you!

share|improve this question
    
I don't like files being stored externally on file hosting services which open browser windows with promotionial content when I try to open your files to debug. –  Stefan Kottwitz Dec 8 '10 at 2:35
    
@Stefan: Sorry about that; it was the first free file sharing host I found. –  Dave Jarvis Dec 8 '10 at 3:39
    
not a big problem :-) there may be free and opensource pastebin services too. But the best is always to reduce to a handy example. ;-) LyX files are also just in text format and could be posted. –  Stefan Kottwitz Dec 8 '10 at 13:04
    
@Stefan: Will find a pastebin for next time; I just cannot bear to paste huge code snippets. (Now if there was a way to "fold" or close the snippet, that would be altogether different.) –  Dave Jarvis Dec 8 '10 at 14:30
    
I would like to see a code folding feature, unfortunately it has been declined: meta.stackoverflow.com/questions/5199/… –  Stefan Kottwitz Dec 8 '10 at 15:24
add comment

1 Answer

up vote 5 down vote accepted

What does this harmless subsection command? It starts a new page! And this page has a different page style. The first page has page style plain because it's the beginning of a chapter, but the next page has scrheadings style. There we may search the problem.

It is in your preamble:

\rehead{\textsc{\ChapterTitle \ChapterNumberIfNeededEven}}
\lohead{\textsc{\ChapterNumberIfNeededOdd \ChapterTitle}}
...
\def\ChapterNumberIfNeededEven{%
  \ifnum 0<\thechapter{} $ \star $ \chaptername{} \thechapter{} \fi
}
\def\ChapterNumberIfNeededOdd{%
  \ifnum 0<\thechapter{} \chaptername{} \thechapter{} $ \star $ \fi
}

Don't compare a number 0 with \thechapter - in your appendix \thechapter is "A" ! Instead, something like

 \ifnum\value{chapter}=0 ...

could work.

On a plain chapter starting page that error could not occur.

share|improve this answer
    
Thank you. –  Dave Jarvis Dec 8 '10 at 3:45
    
Most compiled languages tell you the line or the expression (macro) that caused the error. I suppose that's the only thing about (La)TeX I dislike: when an error happens you have to make inferences and re-examine everything. Since LyX was not creating the page (due to the error), I could not see that it was a new page causing the problem. And I had long since forgotten about the code I wrote to change the chapter heading ("set it and forget it"). Anyway, thanks again. –  Dave Jarvis Dec 8 '10 at 14:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.