GeneralHow to debug latex file?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
gunnar
Posts: 2
Joined: Sat Oct 17, 2009 11:17 pm

How to debug latex file?

Post by gunnar »

Hello.
I've just gotten an error with my latex file. I get

Code: Select all

! TeX capacity exceeded, sorry [main memory size=3000000].
\mathsm@sh #1#2->\setbox \z@ \hbox {$\m@th #1{#2}$
                                                  }\finsm@sh
l.27933 ...rightarrow{a}=\lambda\overrightarrow{b}
                                                  $.
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.
so I wonder if there are any ways of debuging the latex file to find the error? Are there any guides on finding these kind of errors?
I guess I could start by removing stuff until I find a command that when not there, does not result in an error.
But since the file is 1300kb source code I fear too much manual labour on this.

Now I'll just speculate:
I guess that latex uses some of the main memory through its work, but allocated memory is freed when done with some parts, and it can continue on, but if something causes it to loop that eats all the memory or a not closed environment or something other problematic, would that not be easy to find, in some sense since all the memory would soon be used and you could back track where it started to just allocate and not release? :?

I'm very grateful for any help on this. :) I think it's TexLives fault. I used tetex but switched to TeXLives some time ago and some packages were removed and I've tried to replace them. So I guess I've missed something that concerns images.

Recommended reading 2024:

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

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

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: How to debug latex file?

Post by josephwright »

Almost always this type of message arises due to an error in some macro creation, leading to an infinite loop which terminates when TeX runs out of storage. I'm afraid the best way is usually to cut down or comment out code until you isolate the issue.
Joseph Wright
gunnar
Posts: 2
Joined: Sat Oct 17, 2009 11:17 pm

How to debug latex file?

Post by gunnar »

Well I found one thing that caused an error:
\end{sol}\end{ug}

writing it as
\end{sol}
\end{ug}
solved the problem.

I must have forgotten some of all I've learnt about latex, but I thought that having them on the same line would not matter.
I was obviously wrong or have I missed something?

Code: Select all

\documentclass[11pt,oneside,swedish]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[a4paper]{geometry}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{framed}
\usepackage{answers}

\Newassociation{sol}{Svar}{ans}
\newtheorem{uppg}{Uppgift}[chapter]
\newenvironment{ug}{\begin{leftbar}\begin{uppg}\normalfont}{\end{uppg}\end{leftbar}}


\makeatother

\usepackage{babel}

\begin{document}
\Opensolutionfile{ans}[ans1]

\begin{ug}
Show\begin{sol} Proof \end{sol}\end{ug}

\Closesolutionfile{ans}

\end{document}
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

How to debug latex file?

Post by phi »

gunnar wrote:Well I found one thing that caused an error:
\end{sol}\end{ug}

writing it as
\end{sol}
\end{ug}
solved the problem.

I must have forgotten some of all I've learnt about latex, but I thought that having them on the same line would not matter.
I was obviously wrong or have I missed something?
Under normal circumstances, the first code is indeed correct. However, the answers package uses a verbatim-like environment that requires its \end line to stand alone in one line. This is similar to other environments like filecontents, verbatim or listings.
Post Reply