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

xcolor glitches

50 views
Skip to first unread message

Don

unread,
Jul 23, 2007, 11:01:35 PM7/23/07
to
+AMDG

I've been having some trouble with xcolor (it happens with color,
too), but I've been unable to reliably duplicate it. Basically, color
doesn't seem to like being nested. I define a command like so:

\newcommand\markup[1]{%
\noindent\footnotesize\textcolor{red}{#1}
}

I then apply it like so:

\markup{So and so is such and such all the time.}

So far, so good; the text turns out red the way it's supposed to.
Then, however, I try something like this:

\markup{So and so is such and such \textcolor{black}{for this reason}
all the time.}

This will sporadically, and with no apparent rhyme or reason that I
can figure out, cause xcolor to freak out in very unpredictable ways.
Parts will be black which are not within the black brackets; stuff
will be red which ought to be black. I can only presume that
\textcolor is angry that I tried to nest it, but I seems like it
should work, and the package documentation doesn't give me any caution
about doing so.

I can't just end the \markup{} and then start it again, because that
would increase the text back to \normalsize, which I don't want. Any
thoughts?

Message has been deleted

Heiko Oberdiek

unread,
Jul 24, 2007, 2:49:32 AM7/24/07
to
Don <dgood...@gmail.com> wrote:

> I've been having some trouble with xcolor (it happens with color,
> too), but I've been unable to reliably duplicate it. Basically, color
> doesn't seem to like being nested. I define a command like so:
>
> \newcommand\markup[1]{%
> \noindent\footnotesize\textcolor{red}{#1}
> }

* \footnotesize is not limited to its argument.
Surround it by a group or put it into \textcolor.
* The line spacing is set at the end of the paragraph.
If \markup is always a whole paragraph, then put
\par at the end with active \footnotesize.
* The definition contains a probably unwanted space by
the line end.

> I then apply it like so:
>
> \markup{So and so is such and such all the time.}
>
> So far, so good; the text turns out red the way it's supposed to.
> Then, however, I try something like this:
>
> \markup{So and so is such and such \textcolor{black}{for this reason}
> all the time.}
>
> This will sporadically, and with no apparent rhyme or reason that I
> can figure out, cause xcolor to freak out in very unpredictable ways.
> Parts will be black which are not within the black brackets; stuff
> will be red which ought to be black. I can only presume that
> \textcolor is angry that I tried to nest it,

No, xcolor and \textcolor are fine. You should provide a minimal
example. Also you don't say, which driver you are using.

The color problems that I know are caused by the missing color
stack of an older pdfTeX. Page breaks are involved in this kind of
problems.
Best is to update pdfTeX and pdftex.def. In case of older pdfTeX
you can try package pdfcolmk.

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

Heiko Oberdiek

unread,
Jul 24, 2007, 2:55:03 AM7/24/07
to
Herbert Voss <herb...@googlemail.com> wrote:

> Don wrote:

> > \newcommand\markup[1]{%
> > \noindent\footnotesize\textcolor{red}{#1}
> > }
> >

> > \markup{So and so is such and such \textcolor{black}{for this reason}
> > all the time.}
>
> \markup{So and so is such and such {\color{black}for this reason}
> all the time.}
>
> should work

And so does

\documentclass{article}
\usepackage{xcolor}


\newcommand{\markup}[1]{%
\noindent

\textcolor{red}{\footnotesize #1}%
}

\begin{document}


\markup{So and so is such and such \textcolor{black}{for this reason}
all the time.}

\end{document}

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

Don

unread,
Jul 24, 2007, 12:01:28 PM7/24/07
to
+AMDG

> No, xcolor and \textcolor are fine. You should provide a minimal
> example. Also you don't say, which driver you are using.

As I stated, I had been unable to reliably duplicate the problem; thus
a minimal example was impossible.

So I went ahead and duplicated the code precisely; when I'd tried to
duplicate the error before, I'd left out babel. This consistently
messes up, at least on my system, though pdflatex messes up slightly
less than dvips and dvipdfm. I've left one column (the English
column) the way I originally had it coded, and then the other (the
Latin column) coded as suggested, simply dropping out of the \instruct
environment (\markup in my original question); both don't produce
expected results. Here's the code:

\documentclass{article}
\title{Trivial Test for Glitch}
\author{Donald Goodman}
\date{\today}

\usepackage{xcolor}
\usepackage{parcolumns}
\usepackage[latin,english]{babel}

\newcommand{\instruct}[1]{%
\noindent\footnotesize\textcolor{red}{#1}%
}

\newcommand{\latin}[1]{%
\foreignlanguage{latin}{#1}%
}

\begin{document}

\begin{parcolumns}[colwidths={1=2.3in,2=2.3in},sloppy]{2}
\colchunk[1]{\latin{%
\instruct{Et non dicitur versus} Fidelium anim{\ae}, \instruct{sed
immediate subiungitur antiphona finalis beat\ae\ Mari\ae\ Virginis}
\pageref{finantiph}.
}}
\colchunk[2]{%
\instruct{And the verse \textcolor{black}{May the souls of the
faithful} is not
said, but the final antiphon of the Blessed Virgin Mary,
\textcolor{black}{\pageref{finantiph},} is immediately joined.}
}
\end{parcolumns}

\end{document}

The documentation for none of these packages indicates that there
might be a problem, so far as I've been able to tell. I tried this in
simple latex, dvips, dvipdfm, and pdflatex.

Thanks again.

Don

Don

unread,
Jul 24, 2007, 12:22:10 PM7/24/07
to
+AMDG

I forgot to mention: I tried the following, also; I got the same
result with all of them.

> * \footnotesize is not limited to its argument.
> Surround it by a group or put it into \textcolor.

> * The line spacing is set at the end of the paragraph.
> If \markup is always a whole paragraph, then put
> \par at the end with active \footnotesize.

It's not always a full paragraph.

> * The definition contains a probably unwanted space by
> the line end.

Thanks for the pointer; this is fixed.

Don

Robin Fairbairns

unread,
Jul 26, 2007, 10:09:06 AM7/26/07
to

surely this is "just another" colour stack problem? since you have
parallel flows from parcolumns, it seems to me that you need two
colour stacks for page breaking: i bet nothing in all the packages
you're using is taking account of colour-over-page-break issues.

heiko -- does this sound plausible to you?
--
Robin Fairbairns, Cambridge

Don

unread,
Jul 26, 2007, 12:28:34 PM7/26/07
to
+AMDG

> surely this is "just another" colour stack problem? since you have
> parallel flows from parcolumns, it seems to me that you need two
> colour stacks for page breaking: i bet nothing in all the packages
> you're using is taking account of colour-over-page-break issues.

This is the first time I've tried using color to any significant
degree, so I'm ignorant. Testing your suggestion, I find that there's
no problem except when the changed color breaks over lines, and it
seems to relate somewhat to the color in the parallel lines, though I
wasn't able to figure out consistently how. No examples, since I made
lots of minor changes to try to figure it out, and that would make
this posting prohibitively large.

I quick Google search gives me pdfcolmk.sty as a solution to similar
problems with color in hyperref pagebreaks; is there anything similar
that might work here? The documentation of pdfcolmk indicates it
won't support multiple text streams, which I understand is how
parcolumns works.

Thanks again.

Don

Robin Fairbairns

unread,
Jul 26, 2007, 12:33:23 PM7/26/07
to

i've no (real) idea how it might be made to work, which is why i asked
heiko about the possibilities -- if he doesn't know, i would be
surprised if anyone does. pdfcolmk is actually outdated by the latest
pdftex (1.40.*), which has built-in multiple colour stacks. whether
they can be harnessed for your needs ... who knows?
--
Robin Fairbairns, Cambridge

Dan

unread,
Jul 26, 2007, 2:41:01 PM7/26/07
to
On Jul 26, 9:09 am, r...@cl.cam.ac.uk (Robin Fairbairns) wrote:

The parcolumns package (it seems to me) stores both paragraphs
in boxes and then takes them apart into lines with \vsplit, placing
line1 of para1, then line1 of para2, and so on, alternating. If you
examine where the color specials end up, it is clear that the output
color is following them precisely, but in left-to-right order rather
than
down one column and then the next. Thus
<red>Dubito ergo cogito, <black>I doubt therefore I think,
cogito ergo sum<black> I think therefore I am<red>
... ... ...

"cogito" is black because the black on the line above comes
before it. The third line is red for similar reasons. It is not
(quite)
a case of page/column breaking because in the dvi it consists
of alternating left then right boxes, not a single column broken
in the middle. The splitting into lines is obtained with the \vsplit
primitive, and I could not detect any concern for color grouping
in the parcolumns code.


Dan

Heiko Oberdiek

unread,
Jul 26, 2007, 2:44:54 PM7/26/07
to
Don <dgood...@gmail.com> wrote:

> +AMDG
>
> > surely this is "just another" colour stack problem? since you have
> > parallel flows from parcolumns, it seems to me that you need two
> > colour stacks for page breaking: i bet nothing in all the packages
> > you're using is taking account of colour-over-page-break issues.
>
> This is the first time I've tried using color to any significant
> degree, so I'm ignorant. Testing your suggestion, I find that there's
> no problem except when the changed color breaks over lines, and it
> seems to relate somewhat to the color in the parallel lines, though I
> wasn't able to figure out consistently how. No examples, since I made
> lots of minor changes to try to figure it out, and that would make
> this posting prohibitively large.
>
> I quick Google search gives me pdfcolmk.sty as a solution to similar
> problems with color in hyperref pagebreaks;

pdfcolmk.sty is completely independent from hyperref.

> is there anything similar that might work here?

pdfTeX 1.40 and pdftex.def from this year supersedes pdfcolmk.
Furthermore

> The documentation of pdfcolmk indicates it
> won't support multiple text streams, which I understand is how
> parcolumns works.

pdfTeX 1.40 supports multiple text streams.
As example I have written package pdfcolfoot that
adds a separate color stack for footnotes.

In a similar way parcolumn could be extended.

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

Heiko Oberdiek

unread,
Jul 26, 2007, 2:44:54 PM7/26/07
to
rf...@cl.cam.ac.uk (Robin Fairbairns) wrote:

> surely this is "just another" colour stack problem?

Yes.

> since you have
> parallel flows from parcolumns, it seems to me that you need two
> colour stacks for page breaking:

Yes.

> i bet nothing in all the packages
> you're using is taking account of colour-over-page-break issues.
>
> heiko -- does this sound plausible to you?

Yes.

pdfTeX 1.40 offers additional color stacks. Thus the problem
can be solved, if there is a volunteer for extending parcolumns.
As example I had written package pdfcolfoot where a separate
color stack is used for the footnotes.

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

Don

unread,
Jul 26, 2007, 3:42:19 PM7/26/07
to
+AMDG

Thanks for all the help, everyone. I guess I'll have to try to
"extend" parcolumns (though I'm not really that much of a LaTeXpert;
the best I'll manage is a very hard-wired hack, I'm afraid). I
suppose I'd have to add the equivalent of \pdfcolfoot@switch into the
definition of \colchunk, or some internal macro. Thanks again.

Don

Heiko Oberdiek

unread,
Jul 26, 2007, 3:59:41 PM7/26/07
to
Heiko Oberdiek <ober...@uni-freiburg.de> wrote:

> pdfTeX 1.40 offers additional color stacks. Thus the problem
> can be solved, if there is a volunteer for extending parcolumns.
> As example I had written package pdfcolfoot where a separate
> color stack is used for the footnotes.

Add \usepackage{parcolumns-colorstacks}.

%%% cut %%% parcolumns-colorstacks.sty %%% cut %%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{parcolumns-colorstacks}%
[2007/07/26 Add color stack support (HO)]%
%
% Check pdfTeX and pdftex.def for color stack support
%
\expandafter\ifx\csname pdfcolorstackinit\endcsname\relax
\PackageWarningNoLine{parcolumns-colorstacks}{%
Your pdfTeX version does not support color stacks%
}%
\expandafter\endinput
\fi
\@ifpackageloaded{color}{}{\RequirePackage[pdftex]{color}}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname @pdfcolorstack\endcsname\relax
\PackageWarningNoLine{parcolumns-colorstacks}{%
Your pdftex.def is too old, you need at least 2007/01/02 v0.04b%
}%
\expandafter\endinput
\fi
\RequirePackage{parcolumns}
%
% Color stack macros
%
% \pcCol@InitStacks: reserve stacks for all columns
% #1: number of columns
\def\pcCol@InitStacks#1{%
\begingroup
\count@\z@
\loop
\ifnum\count@<#1\relax
\advance\count@\@ne
\@ifundefined{pcCol@Stack\the\count@}{%
\expandafter\xdef\csname pcCol@Stack\the\count@\endcsname{%
\pdfcolorstackinit direct{0 g 0 G}%
}%
}{}%
\repeat
\endgroup
}
%
% \pcCol@UseStack: switch the color stack to the stack for this column
% #1: number of column
\def\pcCol@UseStack#1{%
\expandafter\let\expandafter\@pdfcolorstack
\csname pcCol@Stack\number#1\endcsname
}
%
% \pcCol@SetCurrent: set the current color of the color stack
% #1: number of column
\def\pcCol@SetCurrent#1{%
\pdfcolorstack\csname pcCol@Stack\number#1\endcsname
current\relax
}
%
% Patch color stack macros into macros of package parcolumns.
%
% \pcCol@InitStacks should go into the definition of
% environment parcolumns. \pc@alloccolumns is executed
% there and nowhere else, thus we hook into it:
\g@addto@macro\pc@alloccolumns{%
\pcCol@InitStacks\pc@columncount
}
%
% \pcCol@UseStack should go into the definition of \colchunk@
% \pc@setcolumnwidth is used as carrier.
\g@addto@macro\pc@setcolumnwidth{%
\pcCol@UseStack\pc@columnctr
}
%
% \pcCol@SetCurrent is set at the begin of each line.
\renewcommand*{\pc@placeboxes}{%
\global\let\@tempa\relax
\count@\z@
\hb@xt@\linewidth{%
\vfuzz30ex %
\vbadness\@M
\splittopskip\z@skip
\loop
\ifnum\count@<\pc@columncount
\advance\count@\@ne
\expandafter\ifvoid\csname pc@column@\number\count@\endcsname
\hskip\csname pc@column@width@\number\count@\endcsname
\else
\expandafter\setbox\expandafter\@tempboxa\expandafter
\vsplit\csname pc@column@\number\count@\endcsname
to \dp\strutbox
\vbox{%
\pcCol@SetCurrent\count@
\unvbox\@tempboxa
}%
\fi
\expandafter\ifvoid\csname pc@column@\number\count@\endcsname
\else
\global\let\@tempa\pc@placeboxes
\fi
\ifnum\count@<\pc@columncount
\strut
\hfill
\ifpc@rulebetween
\vrule
\hfill
\fi
\fi
\repeat
}%
\@tempa
}
\endinput
%%% cut %%% parcolumns-colorstacks.sty %%% cut %%%

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

Heiko Oberdiek

unread,
Jul 26, 2007, 4:01:00 PM7/26/07
to
Don <dgood...@gmail.com> wrote:

> Thanks for all the help, everyone. I guess I'll have to try to
> "extend" parcolumns (though I'm not really that much of a LaTeXpert;

I have done it already, see the previous posting.

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

Don

unread,
Jul 26, 2007, 4:35:21 PM7/26/07
to
+AMDG

Wow; thanks. This group is more help than I've ever found on usenet.

Don

Don

unread,
Aug 28, 2007, 1:37:58 PM8/28/07
to
+AMDG

Heiko, as I've been unable to break your package code
parcolumns_colorstacks.sty no matter how hard I try, I wanted to the
author of parcolumns to see if he wanted to include it in the next
version (with full credit to you as the author, of course). Do you
have any objection to this?

Don

Heiko Oberdiek

unread,
Aug 28, 2007, 2:53:00 PM8/28/07
to
Don <dgood...@gmail.com> wrote:

No. Let me know, what he decides.

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

Heiko Oberdiek

unread,
Sep 19, 2007, 11:30:29 AM9/19/07
to
Heiko Oberdiek <ober...@uni-freiburg.de> wrote:

> Don <dgood...@gmail.com> wrote:
>
> > Heiko, as I've been unable to break your package code
> > parcolumns_colorstacks.sty no matter how hard I try, I wanted to the
> > author of parcolumns to see if he wanted to include it in the next
> > version (with full credit to you as the author, of course). Do you
> > have any objection to this?
>
> No. Let me know, what he decides.

I heard neither of you or the author, thus I have put
the package under the name `pdfcolparcolumns' on CTAN
to prevent the code from getting lost.

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

0 new messages