Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

\color{ } problems.. :Out of stack space..

29 views
Skip to first unread message

Deepak Goel

unread,
Aug 30, 2000, 3:00:00 AM8/30/00
to

I am switching color via \color{ } a lot in my 14-page document, about 300
times in total.


Am using latex2e, and my document contains no "tex" command, all latex, so
i figure there should be no problem.

But every once in a while, the document refuses to compile:

latex <file>
latex <file>
dvips <file>.

dvips gives an error ---- "Out of stack space".

Miraculously, sometimes: if i go and make some more changes in the file
(thus *increasing* the size of the file), then it seems to compile.


Any help would be greatly appreciated.

Thanks.

Deepak
--


Heiko Oberdiek

unread,
Aug 30, 2000, 7:12:07 PM8/30/00
to
Deepak Goel <de...@Glue.umd.edu> wrote:

>I am switching color via \color{ } a lot in my 14-page document, about 300
>times in total.
>

>dvips gives an error ---- "Out of stack space".
>
>Miraculously, sometimes: if i go and make some more changes in the file
>(thus *increasing* the size of the file), then it seems to compile.

Each color setting command adds an entry on the stack,
after the current group, the entry is removed from the
stack. Therefore it is better to use \color locally in
small groups than globally or in large groups with many
color commands.

If most of your color commands are outside of all groups,
then the package below will help, if used with e-TeX:

%%% cut %%% dvipscol.sty %%% cut %%%
% File: dvipscol.sty
% Version: 2000/08/31 v1.0
% Author: Heiko Oberdiek
% Email: <ober...@ruf.uni-freiburg.de>
%
% Copyright: Copyright (C) 2000 Heiko Oberdiek.
%
% This program may be distributed and/or modified under
% the conditions of the LaTeX Project Public License,
% either version 1.2 of this license or (at your option)
% any later version. The latest version of this license
% is in
% http://www.latex-project.org/lppl.txt
% and version 1.2 or later is part of all distributions
% of LaTeX version 1999/12/01 or later.
%
% Function: This package tries a solution, if the program
% dvips complains:
% "! out of color stack space"
% The driver file `dvips.def' contains the
% low level color commands for the package `color'.
% Each time a color is set, the current color is
% pushed on the color stack before and after the
% current group the old color is popped from
% the stack and set again (via \aftergroup).
% But the color stack size of dvips is limited,
% so a stack overflow can occur, if there are
% too many color setting operations in a group.
% Only at the bottom group level (no group),
% the color can be set directly without pushing
% the current color on the stack before, because
% there is no group at bottom level that can end.
% With e-TeX the group level can easily be
% detected (\currentgrouplevel). Alone with TeX
% this is not possible.
%
% Recommended: e-TeX (explanation see above)
%
% Use: * With e-TeX the package fixes \set@color, therefore
% no interaction with the user is required.
% * Without e-TeX the package defines \nogroupcolor,
% that the user can use manually instead of \color.
% But caution: it should only be used outside of all
% groups, for example the following will not work:
% \textcolor{black}{\nogroupcolor{blue}...}
%
% History: 2000/08/31 v1.0:
% first public release created as answer to
% a question of Deepak Goel in comp.text.tex:
% "\color{} problems.. :Out of stack space.."
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{dvipscol}[2000/08/31 v1.0 Fix for dvips.def (HO)]

\@ifundefined{v...@dvips.def}{%
\PackageWarningNoLine{dvipscol}{%
Nothing to fix, because \string`dvips.def\string' not loaded%
}%
\endinput
}

\CheckCommand*{\set@color}{%
\special{color push \current@color}%
\aftergroup\reset@color
}

\newcommand*{\nogroupcolor}{%
\let\saved@org@set@color\set@color
\def\set@color{%
\let\set@color\saved@org@set@color
\special{color \current@color}%
}%
\color
}

\ifx\currentgrouplevel\@undefined
\PackageWarningNoLine{dvipscol}{%
\string\set@color\space cannot be fixed, %
because the\MessageBreak
e-TeX extensions are not available%
}%
\expandafter\endinput
\fi
\def\set@color{%
\ifcase\currentgrouplevel
\special{color \current@color}%
\else
\special{color push \current@color}%
\aftergroup\reset@color
\fi
}
\endinput
%%% cut %%% dvipscol.sty %%% cut %%%

Yours sincerely
Heiko <ober...@ruf.uni-freiburg.de>

0 new messages