5

I'm using the instant preview feature in LyX, which as I understand is based on a LaTeX package of the same name. As I have LyX configured with a dark background -

Is there anyway to configure the instant preview to output a different color (say white)?



Edit:

It appears that LyX is using dvipng through preview.sty to generate the output, which does have a color option. If I knew where dvipng was being called from, perhaps I could add the color flag, but I can't seem to find it.

7
  • Just to be clear, what exactly is the name of the LaTeX package? It likely comes with documentation. Jun 4, 2014 at 3:25
  • @SeanAllred - I think it's: /usr/share/texmf/tex/latex/preview/preview.sty
    – nbubis
    Jun 4, 2014 at 3:32
  • Thanks :) For reference, something like preview is descriptive enough :) from here, we can look at CTAN's listing. Jun 4, 2014 at 4:13
  • If you go to Tools -> Preferences -> File handling -> Converters, you'll find LyX Preview in the list. That points to a Python script called lyxpreview2bitmap.py that is (I think) in /usr/share/lyx/scripts/. I haven't looked too closely at the script yet, but perhaps you can figure it out. (If this is helpful I can add a proper answer.) Jun 8, 2014 at 7:00
  • @TorbjørnT. - Thank you. Although the script has a color flag, it's not clear where the 6 command line arguments are coming from. If you wish to add an answer, a bounty awaits :)
    – nbubis
    Jun 8, 2014 at 7:06

3 Answers 3

2
+50

Under Tools --> Preferences -> File handling -> Converters, there is an entry called LyX Preview -> PNG. The converter given for this entry is

python -tt $$s/scripts/lyxpreview2bitmap.py

$$s is a placeholder that, as I understand it, points to the LyX library directory, which can be /usr/share/lyx/ on a Linux system. Open Help --> About LyX to see the path to that directory.

That script is called with six arguments, though exactly where and how it is called I cannot say, so I don't know how to modify that. As a bad hack you could set fg_color (and/or bg_color) explicitly to a colour of your choice, in lines 300-301 of lyxpreview2bitmap.py, or in the call to dvipng (line 372). Not a very good workaround though.

0
1

It looks like in newer version of LyX one can simply change the command under Tools / Preferences / File handling / Converters / LyX Preview -> PNG to:

python -tt $$s/scripts/lyxpreview2bitmap.py --png --fg="ccffff"

Where in this example #ccffff was chosen as the foreground color.

0

My LyX version is 2.2.1, If you check the codes of lyxpreview2bitmap.py, it has its options:

>   --dpi=<res>:   Resolution per inch (default: 128)   --png, --ppm: 
> Select the output format (default: png)   --fg=<color>:  Foreground
> color (default: black, ie '000000')   --bg=<color>:  Background color
> (default: white, ie 'ffffff')   --latex=<exe>: Specify the executable
> for latex (default: latex)   --bibtex=<exe>: Specify the executable
> for bibtex (default: bibtex)   --lilypond:    Preprocess through
> lilypond-book (default: false)   --lilypond-book=<exe>:
>                  The executable for lilypond-book (default: lilypond-book)
> 
>   -d, --debug:   Show the output from external commands   -h, --help: 
> Show this help screen and exit   -v, --verbose: Show progress messages
> 
> The colors are hexadecimal strings, eg 'faf0e6'."""

Like @nbubis showed, we can click "modify" button for "LyX Preview -> PNG", which can be found by searching "lyxpreview2bitmap" in LyX: Preferences. another example can be:

python -tt $$s/scripts/lyxpreview2bitmap.py --png --fg="3f38cf" --bg="faf0e6"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .