Skip to content

LaTeX: refactor sphinxShadowBox to allow colors for frame and shadow - #10619

Merged
jfbu merged 2 commits into
sphinx-doc:5.xfrom
jfbu:latex_coloredshadows
Jul 3, 2022
Merged

jfbu merged 2 commits into
sphinx-doc:5.xfrom
jfbu:latex_coloredshadows

Conversation

@jfbu

@jfbu jfbu commented Jun 30, 2022 •

Copy link
Copy Markdown
Contributor

This adds possibility of colors for the "shadowed" box used for the topic and contents directives.

No change to existing output, as default colors left to black.

Here is an example of use:
Capture d’écran 2022-06-30 à 19 51 33

(the box allows pagebreaks as formerly, this is not shown here)

The example uses:

latex_elements = {
    'sphinxsetup': """%
  shadowrule=2pt,%
  shadowsize=6pt,%
  shadowShadowColor={RGB}{170,170,170},%
""",
}

in conf.py.

edit. I messed up horizontal width, will fix later to maintain behaviour as current. Well I wll never understood what went wrong, so I redid it entirely, and the code is much closer to current one.

Here is an example of use with a page break, to show no color leaks:
Capture d’écran 2022-06-30 à 22 34 04

Topics
------

Hello

.. raw:: latex

   \rule{1cm}{1cm} \hrulefill \rule{1cm}{1cm}

.. topic:: Some topic

   .. raw:: latex

      \begingroup\color{blue}

   Some contents possibly very long, we added color via raw latex, to check
   nothing bad happen even at at page break. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. Some contents possibly very long. Some
   contents possibly very long. 

   .. raw:: latex

      \endgroup

.. raw:: latex

   \rule{1cm}{1cm} \hrulefill \rule{1cm}{1cm}

with conf.py:

latex_elements = {
    'sphinxsetup': """%
  shadowrule=10pt,%
  shadowsize=20pt,%
  shadowShadowColor={RGB}{170,170,170},%
  shadowBorderColor={RGB}{255,0,0},%
""",
}

@jfbu jfbu added type:enhancement enhance or introduce a new feature builder:latex labels Jun 30, 2022
@jfbu jfbu added this to the 5.1.0 milestone Jun 30, 2022
@jfbu
jfbu marked this pull request as draft June 30, 2022 18:03
@jfbu
jfbu force-pushed the latex_coloredshadows branch from 8153dbf to 6afde2e Compare June 30, 2022 20:42
@jfbu
jfbu marked this pull request as ready for review June 30, 2022 20:48

@tk0miya tk0miya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jfbu

jfbu commented Jul 3, 2022

Copy link
Copy Markdown
Contributor Author

Thanks as always for reviewing @tk0miya! I thought about adding interface for coloring the contents but it is now available to Sphinx user via something such as

\protected\def\sphinxstyletopictitle #1{\leavevmode\color{red}% color for contents
                                \textcolor{green}{\textbf{#1}}% colored title
                                \par\medskip}

(btw I don't think the \protected is needed here but it is currently present in sphinxlatexstyletext.sty).
With current 5.x, the above code would have leaked the text color (red in this example) to the shadow and part of the frame. Now with this PR merged the above user configuration will modify only contents color, so it can be used safely. Anyhow, contents topic boxes contain hyperlinks which have their own coloring...and above user config will impact only color of the box title from contents directive. Text paragraphs color will be changed by above user config for topic boxes.

Now merging...

@jfbu
jfbu merged commit aae64ba into sphinx-doc:5.x Jul 3, 2022
jfbu added a commit that referenced this pull request Jul 3, 2022
@jfbu
jfbu deleted the latex_coloredshadows branch July 3, 2022 10:16
jfbu added a commit to jfbu/sphinx that referenced this pull request Jul 10, 2022
Indeed shadowBorderColor and shadowShadowColor added at sphinx-doc#10619 are now
named respectively:

aside.topic-border-TeXcolor

and

aside.topic-box-shadow-TeXcolor

And a new parameter

aside.topic-background-TeXcolor

has been added.
jfbu added a commit to jfbu/sphinx that referenced this pull request Jul 10, 2022
Indeed shadowBorderColor and shadowShadowColor added at sphinx-doc#10619 are now
named respectively:

aside.topic_border-TeXcolor

and

aside.topic_box-shadow-TeXcolor

And a new parameter

aside.topic_background-TeXcolor

has been added.
@jfbu

jfbu commented Jul 10, 2022

Copy link
Copy Markdown
Contributor Author

This got refactored at #10648 with new names aside.topic_border-TeXcolor and aside.topic_box-shadow-TeXcolor and addition of possibility of having a background color aside.topic_background-TeXcolor.

jfbu added a commit to jfbu/sphinx that referenced this pull request Jul 14, 2022
- LaTeX: box padding (t,r,b,l), borders (t,r,b,l), shadows (x,y) or radii

- LaTeX: fix sphinx-doc#10650 via usage of our own sophisticated \fcolorbox

- LaTeX: user interface via 'sphinxsetup' to enhanced code-blocks frames

- LaTeX: user interface via 'sphinxsetup' to enhanced topic boxes

- LaTeX: CSS-named-alikes 'sphinxsetup' options for code-blocks and
  topics

- LaTeX: CSS-named-alikes 'sphinxsetup' keys for warning type notices
  (fix sphinx-doc#10651)

- LaTeX: documentation of the new CSS-like options

- LaTeX: remove sphinx-doc#10619 documentation, as the sphinx-doc#10619 added
  shadowBorderColor and shadowShadowColor now named respectively:

  aside.topic_border-TeXcolor and aside.topic_box-shadow-TeXcolor

- LaTeX: use div.topic option prefix and not aside.topic for CSS-like
  options

- LaTeX: keep the implicit legacy padding of warning type boxes as
  default behaviour
@jfbu

jfbu commented Jul 14, 2022

Copy link
Copy Markdown
Contributor Author

was superseded by #10648

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

builder:latex type:enhancement enhance or introduce a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants