Skip to content

LaTeX: change defaults for admonition or code-block colors from white or black as currently used #10620

@jfbu

Description

@jfbu

I have tested some configuration, vaguely motivated to have about same colors for PDF rendering as in the default HTML theme, Alabaster.

My main motivation is for code-blocks where I feel the framing is distractive, and I feel a light grey background colour would be better. But I have not tested what it gives on printed paper.

Here is the configuration I tried (with the proposal to make it the default at 6.0.0). Mainly colors are changed and a few widths.

latex_elements = {
    'sphinxsetup': """%
  VerbatimColor={RGB}{230,230,230},%
  verbatimwithframe=false,
  verbatimsep=5pt,
%       shadowBorderColor={RGB}{102,102,102},% requires #10619
%       shadowShadowColor={RGB}{187,187,187},%
  shadowrule=2pt,%
  shadowsize=6pt,%
  noteBorderColor={RGB}{204,204,204},%
  hintBorderColor={RGB}{204,204,204},%
  importantBorderColor={RGB}{204,204,204},%
  tipBorderColor={RGB}{204,204,204},%
  noteborder=5pt,%
  hintborder=5pt,%
  importantborder=5pt,%
  tipborder=5pt,%
  warningBorderColor={RGB}{255,119,119},%
  cautionBorderColor={RGB}{255,119,119},%
  attentionBorderColor={RGB}{255,119,119},%
  dangerBorderColor={RGB}{255,119,119},%
  errorBorderColor={RGB}{255,119,119},%
  warningBgColor={RGB}{255,238,238},%
  cautionBgColor={RGB}{255,238,238},%
  attentionBgColor={RGB}{255,238,238},%
  dangerBgColor={RGB}{255,238,238},%
  errorBgColor={RGB}{255,238,238},%
  % LaTeX code of heavyboxes draws border "inwards" so
  % it must be not too big
  warningborder=3pt,%
  cautionborder=3pt,%
  attentionborder=3pt,%
  dangerborder=3pt,%
  errorborder=3pt,%
""",
}

edit: on second thoughts perhaps keeping verbatimsep=3pt which is current default (it is set to \fboxsep and the latter default to 3pt in LaTeX) is better than the 5pt tried out here

It renders like this (with #10619 merged):

foo-5

foo-6

(the comment about "automatic shift to next page" is too optimistic, it can happen that the unbreakable inner box will stay on first page because it is only one or two baselines too long, and as the frame is drawn latest, it will hide part of the overflowing contents, which can be a problem if the frame is thick enough; alas, one never ends encountering problems with pagebreaks versus boxes in LaTeX...)

foo-7

foo-8

foo-9

project is attached (can be compiled without #10619, some commented things should be uncommented to exploit it)
testnewdefaults.zip

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions