auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX-devel] [gs-devel] Try to colorize preview


From: jfbu
Subject: Re: [AUCTeX-devel] [gs-devel] Try to colorize preview
Date: Mon, 24 Jun 2019 13:00:48 +0200

Dear Keita,

Le 24 juin 2019 à 11:40, Ikumi Keita <address@hidden> a écrit :

> [ I drop Ken and gs-devel from To: and Cc: field for this message. ]


ok


> 
>>>>>> Ikumi Keita <address@hidden> writes:
>> The attached patch #1 (just adding initial TeX codes at execution of
>> pdflatex) works only partially.  Though the background turns its color
>> as expected, the foreground color isn't affected.
> 
>> The situation changes by further modification in preview.sty with the
>> attached patch #2, which uncomments two lines.  Together with the above
>> patch #1, my intent of setting both the foreground and background colors
>> are reflected in the outcome of preview-latex.
> 
> The story changes when I use latex+dvips+gs or latex+dvipng with
> `TeX-PDF-mode' set to nil.  In those cases, the foreground color is
> reflected but the background color is ignored, even if `dvips' option is
> given to color.sty and preview.sty.  So it would be still necessary to
> adjust the colors with elisp functions `preview-gs-color-string' and
> `preview-dvipng-color-string', at least for bakcground color, even with
> the patches #1 and #2.

I briefly tested (but with an unmodified auctex, I did not remove
the gs hack for my tests ; but I don't have any specific colors
in Emacs buffer) that the following patches work
both with pdflatex + gs and with latex + dvipng

(I am attaching to this message the corresponding patch to preview.dtx
for the auctex git-repo
but describe here directly the changes in preview.sty and prauctex.def)

1. we add as previously considered 
\RequirePackage{color}\color{...}\pagecolor{...}
to the (pdf)latex invocation done by AUCTeX to generate previews

2. the preview.sty is modified at two locations :

first:

       \ifpr@auctexmode\begingroup\pagecolor{red}\color@setgroup\fi
        \box\pr@box
       \ifpr@auctexmode\color@endgroup\endgroup\fi


replace the lines you mentioned. I am not sure about really
needing the \begingroup/\endgroup but they don't harm

The other location is to define the \ifpr@auctexmode boolean :
the \newif line is added above the \DeclareOption* line

second:

\newif\ifpr@auctexmode % <<<--- this is added line
\DeclareOption*
   {\InputIfFileExists{pr\CurrentOption.def}{}{\OptionNotUsed}}

3. the prauctex.def file is modified this way

\ifPreview\else\expandafter\endinput\fi
\nofiles
\pr@auctexmodetrue % <<<--- this is added line

The idea of the above is

A) to reactivate the commented out lines you mentioned, but only
for usage of preview.sty with auctex option

B) to insert a mechanism for the page color. In place of
\pagecolor{red} we would need some macro which by default is
\relax but whose definition would be added to the invocation of
preview package from AUCTeX.


The above of course breaks \usepackage[auctex]{preview} if color
package is not loaded due to explicit \pagecolor{red} thing, but
the idea is to replace that by some \prauctexpagecolor macro
whose default would be \relax, and that AUCTeX would define say
\def\prauctexpagecolor{\pagecolor{red}}\pagecolor{red} in
the (pdf)latex invocation.

With this set-up I got correct previews both in PDF mode (gs is
used) and DVI mode (dvipng is used)

I have not tested extensively at all...

... as David mentions in his recent reply 

> Also color.sty produces additional special codes that may interact with
> typesetting.


potentially there could be some interference but I did not encounter it so far.

Best,

Jean-François

Attachment: patchcolor.diff
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]