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.

When I try to add a figure that consists of two subfigures to my document with the following piece of code

\begin{figure}[h]
\centering
\subfloat[Locally confluent]{
\begin{tikzpicture}[>=stealth,font=\sffamily]
    \node (X) at (0,0) {$x$};
    \node (Y) [below left=2cm and 1cm of X]  {$y$};% 2cm below, 1cm to the left (optional)
    \node (Z) [below right=2cm and 1cm of X] {$z$};
    \node (U) [below left=2cm and 1cm of Z]  {$u$};
    \draw [semithick,->] (X) -- (Y);
    \draw [semithick,->] (X) -- (Z);
    \draw [semithick,->] (Y) -- (U) node [midway,below,sloped] {*};
    \draw [semithick,->] (Z) -- (U) node [midway,below,sloped] {*};
\end{tikzpicture}
\label{fig:locallyconfluent}}
\qquad
\subfloat[Confluent]{
\begin{tikzpicture}[>=stealth,font=\sffamily]
    \node (X) at (0,0) {$x$};
    \node (Y) [below left=2cm and 1cm of X]  {$y$};% 2cm below, 1cm to the left (optional)
    \node (Z) [below right=2cm and 1cm of X] {$z$};
    \node (U) [below left=2cm and 1cm of Z]  {$u$};
    \draw [semithick,->] (X) -- (Y) node [midway,above,sloped] {*};
    \draw [semithick,->] (X) -- (Z) node [midway,above,sloped] {*};
    \draw [semithick,->] (Y) -- (U) node [midway,below,sloped] {*};
    \draw [semithick,->] (Z) -- (U) node [midway,below,sloped] {*};
\end{tikzpicture}
\label{fig:confluent}}
\caption{This is a figure containing several subfigures.}
\end{figure}

I get "no room for new \count" errors in my ntheorem.tex file where I include all ntheorem stuff and define all my theorems.

Am I doing something wrong or why is this happening?

share|improve this question
    
Is the error happening when TeX is reading your ntheorem.tex file? This should have no relation with the graphics you're showing, but is probably due to the packages you're loading. Put \usepackage{etex} as the first package, just after the \documentclass line. –  egreg Apr 8 '12 at 20:59
    
@egreg it is. What does etex do? When I use \subfigure, there is no error, but I should not use that because it is depricated, right? –  codd Apr 8 '12 at 21:02
    
The etex package enables the usage of the extended pool of registers. Don't use the subfigure package. However, the error might be due to some programming error and the complete preamble is needed to diagnose it. –  egreg Apr 8 '12 at 21:05
    
please make your example into a complete runnable document loading all packages needed to make the example run, I made a guess but I get different errors to the one you stated. –  David Carlisle Apr 8 '12 at 21:10
add comment

1 Answer

up vote 6 down vote accepted

The No room for a new \count error can originate from two reasons:

  1. The document loads many packages and they try to allocate too many count register than are available;

  2. There is a programming error in some user defined macro.

One should remember that LaTeX has been written when only 256 registers of each type were available and the kernel hasn't been updated to take into account the extended pool made available by e-TeX (that's been used as the typesetting engine for some years). This engine (which is incorporated in pdftex) provides 32768 registers of each type.

If the error shows up one can use the extended pool by loading the etex package:

\documentclass[<options>]{<classname>}
\usepackage{etex}

It should be the first package loaded, usually, so I've put a "generic" \documentclass line. This is useful also when XeLaTeX or LuaLaTeX are used.

This, however, wouldn't solve the second case, but only hide the problem under the carpet. Let's see an example:

\newcommand{\foo}[1]{\newcounter{bar}...}

is wrong, as it allocates a new counter at each call. The kernel allocates 100 of the 256 normally available registers; thus the 157th call of \foo will surely trigger the error. Of course packages loaded in the preamble will allocate other counters (and some allocate many), thus reducing the number of times the (faulty) macro can be called. With etex the error would still be there, only to appear after many more calls of the macro.

A counter should be allocated outside the macro call:

\newcounter{bar}
\newcommand{\foo}[1]{<do something with #1 and the bar counter>}
share|improve this answer
    
I have a lot of macro's that look like your '\foo example. How else should I define them, if you are saying that is wrong? –  codd Apr 8 '12 at 22:17
    
@codd I've edited the answer; but without seeing an example I can only be generic. –  egreg Apr 8 '12 at 22:28
    
@codd just issue \newcounter{bar} once in your package, the command you use each time should set the counter or advance the counter (setcounter or \addtocounter) not declare a new counter each time –  David Carlisle Apr 8 '12 at 22:30
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.