Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX: add \sphinxbox command #11224

Merged
merged 1 commit into from Mar 7, 2023
Merged

LaTeX: add \sphinxbox command #11224

merged 1 commit into from Mar 7, 2023

Conversation

jfbu
Copy link
Contributor

@jfbu jfbu commented Mar 7, 2023

Subject: add \sphinxbox user interface for inline boxes with possibly rounded corners, background color, even a shadow.

Here is for example what one obtains with the code at time of creation of the PR and this user extra in conf.py:

latex_elements = {
    'preamble': r'''
\protected\def\sphinxguilabel#1{\sphinxbox[box_background-TeXcolor=yellow!20,%
                                           boxborder=1pt,%
                                           boxsep=3pt,%
                                           box_border-radius=3pt]{#1}}''',
}

(edit: see next comment for final syntax, no more boxborder, boxsep)

for customized rendering in PDF via LaTeX of the :guilabel: role:

2023-03-07 screenshot

Code is almost done but still WIP due to desire to proceed further with the refactoring of support for CSS-like sphinxsetup options (already in master branch) as there is still potential for sharing some almost identical TeX code which is currently repeated at various places, and got again repeated in the definition of \sphinxbox.

Also perhaps add some \newsphinxbox in the tcolorbox spirit.

And also hesitation about defaults.

(we can discuss separately the specific #11213 question about :guilabel:, whether to modify its default or not).

Expect some force pushes, WIP.

Question about a "display" variant will not be part of this PR, which is only about (unbreakable) "horizontal" boxing, i.e. of inline elements not display elements.

Feature or Bugfix

  • Feature

Related

@jfbu jfbu added this to the 6.2.0 milestone Mar 7, 2023
@jfbu jfbu marked this pull request as draft March 7, 2023 00:19
@jfbu jfbu force-pushed the latex_sphinxbox branch 2 times, most recently from 8dca35d to 0f7e353 Compare March 7, 2023 10:36
@jfbu jfbu changed the title LaTeX: sphinxbox (WIP) LaTeX: add \sphinxbox command Mar 7, 2023
@jfbu jfbu marked this pull request as ready for review March 7, 2023 12:21
@jfbu
Copy link
Contributor Author

jfbu commented Mar 7, 2023

In the final version, the key names have changed a bit from what is in my initial message on top, no more a boxborder or boxsep but exclusively the CSS-like syntax from 5.1.0.

Here is an example rendering:
Capture d’écran 2023-03-07 à 12 37 11

With this in conf.py

latex_elements = {
    'preamble': r'''
% define a sphinxbox with some defaults:
\newsphinxbox[border-width=4pt,%
              border-radius=4pt,%
              background-TeXcolor=yellow!20]{\foo}
% use this \foo to redefine rendering of some text elements:
\protected\def\sphinxguilabel#1{\foo{#1}}
\protected\def\sphinxmenuselection#1{\foo[background-TeXcolor=green!20,
                                          border-width=1pt,
                                          box-shadow=3pt 3pt,
                                          box-shadow-TeXcolor=gray]{#1}}
% and this one will use \sphinxbox directly
% one can also add options within square brackets as in usage of \foo above
\protected\def\sphinxkeyboard#1{\sphinxbox{\sphinxcode{#1}}}
''',
}

and

Some text before :guilabel:`fa-folder` some text :menuselection:`Edit` some
text :kbd:`Ctrl-x Ctrl-f`

as input.

@jfbu
Copy link
Contributor Author

jfbu commented Mar 7, 2023

Failure of test_gettext_dont_rebuild_mo on Windows does not look to me as being related. So I will merge as I can't be sure of when I can be active here.

@jfbu jfbu merged commit 3a142d9 into sphinx-doc:master Mar 7, 2023
20 of 21 checks passed
@jfbu jfbu deleted the latex_sphinxbox branch March 7, 2023 12:44
jfbu added a commit that referenced this pull request Mar 7, 2023
@n-peugnet
Copy link
Contributor

Excellent! I made my own with tcolorbox as this package makes it easy. But one thing it cannot do is allowing inline boxes to break between words (even less so inside words).

Are these boxes allowed to break? Can it be an option?
Thank you for your work on Sphinx's $\LaTeX$ rendering!

@jfbu
Copy link
Contributor Author

jfbu commented Mar 14, 2023

@n-peugnet Thanks for comment!

About:

Are these boxes allowed to break? Can it be an option?

Sadly, no. I added a comment in the source:

{box-decoration-break}% This one is actually useless, as \sphinxbox
% creates an unbreakable horizontal box, not a breakable vertical
% box. And as is well-known it is very complicated (not to say
% impossible) to create in LaTeX breakable horizontal boxes. No
% package offers them. See the complications for the support of
% verbatimforcewraps in sphinxlatexliterals.sty or see the source
% code of the soul or soulutf8 packages.

With a few more details: I am not aware of a LaTeX package offering fully functional (i.e. with no or very few restrictions on input) breakable horizontal boxes.

  • basically, one has to box individually each character adding invisible glue in-between to allow a line break,
  • but the LaTeX programmer can not assume the input is only composed of character and space tokens,
  • it can be composed of quite a lot of LaTeX commands nested one within the other, or primitive TeX boxing operations, or switch to math mode, etc...
  • even if you insist that input is only stream of characters, a good boxing should not interfere with TeX ligatures and intra-character kerning.

There is a well-known 20+ years old package called soul which attempts to add underlining or other effets, and in particuler background highlighting via its macro \hl. It is unmaintained and for many many years was not compatible with UTF-8 in pdfLaTeX, and very recently, a few weeks ago, LaTeX maintainers merged it with companion "soulutf8" package, which addresses that. Underlining and other effects can also be achieved with the even older ulem package but with any braced content such as a \emph{some words} that part will not break across lines. Here is some example output using the more able soul :
Capture d’écran 2023-03-14 à 10 18 31
where I inserted a nested \emph inside the \hl command of the package: one can see it does obey the line break.

For simply adding a background color, the soul \hl used inside a redefinition of \sphinxguilabel for example should work. However I looked at the package documentation and unfortunately if you want to do anything such as controlling the size of the colored area, you will have to enter somewhat deep into the package code and identify @ letter macros to modify. And I have no idea if it is feasible for example to treat the first and last characters differently.

In the past I have implemented for Sphinx the line-breaking of long code lines highlighted by Pygments: the verbatimwrapslines and verbatimforcewraps options of 'sphinxsetup'. The former was of a nature very different from the issue we discuss here, it was a question of interaction with the LaTeX package used by Sphinx called fancyvrb [1]_. But for the verbartimforcewraps (off by default) it is very similar to the issue here (once the verbatimwrapslines thing has been solved to start with). To implement it I had to hijack the Pygments mark-up to grab character per character.

As long as you control fully the input mark-up you can probably do something. In the case of highlight code, a very important thing is that the \PYG macro is never nested. But for Sphinx LaTeX mark-up of roles, probably some nesting can happen, and it would require time to overview all possibilties. And in pdflatex case, UTF-8 characters are special, one has to identify their "active" first byte, which was the more complex part in my implementation of verbatimforcewraps (notice that in the LaTeX world at large, package authors -- for example for glossary or indexing or bibliography related packages -- have often requested the LaTeX team a robust way to grab the first character of a word, which as far as I know, started having official LaTeX-supported solutions only quite recently, for package authors using the LaTeX3 programming interface). And for doing this I had to support only utf8 I could not support the utf8x which in recent years has become more and more incompatible with upstream LaTeX evolving support of Unicode input.

Let's say you have solved all these problems, there is still some work to do for boxing with decorations such as a border or a shadow or rounded corners as provided by \sphinxbox : rounded corners for example have to apply only for start and finish... so as said above one has to identify the first and last characters and treat them differently from others and as I indicate at end of footnote below, I am running out of time available for Sphinx right now, and for surely at least 4 or 5 months. If it was only a matter to handle a stream of characters it is feasible somewhat quickly, only difficulty is the business of utf-8 in pdflatex. In lualatex or xelatex it is trivial as each Unicode character looks as only one token to TeX.

Thus if you use \sphinxbox, there is currently and for the foreseeable future no breaking of contents across successive lines. If implemented one day, it will have to be activated by some option, as it will go along quite complex extra TeX coding. For a simple background highlighting or underlining or overstriking, you can try the macros such as \hl from package soul however I have no idea how this will work if its input contains nested \sphinx... macros which is not to exclude.

Many years ago I had applied some highlighting of my own in the documentation of a LaTeX package I authored. But all the little colorboxes ended up causing some stack overflow problem (not sure if I was using pdflatex or latex+dvipdfmx though, the latter behaving differently in matters of colors, it can not have multiple color stacks).

Probably the LuaTeX is the more-or-less sole hope that one can do something general: it offers hooks into the node lists created by TeX. Perhaps, probably one can use that. However this would be heavy-duty LuaTeX thing and I am simply lacking both the knowledge and the will to invest time into it. If it was a matter of a one-hour effort perhaps, but this looks more like weeks... and I searched a bit and did not identify a LuaTeX-specific add-on offering this, perhaps it exists nevertheless. (maybe this on overleaf can be a LuaTeX ouverture).

(perhaps if you ask on a LuaTeX forum they will tell you of course it is well-known and you only have to do this or that...)

.. [1]: digression: it is a historical legacy from prehistory of package that Sphinx uses fancyvrb for code-blocks, the principal reason being to actually force input lines to give one-to-one output lines, i.e. deactivate the paragraph reflowing ; in retrospect there was much simpler way to do this than employ fancyvrb which also is designed to escape all special-to LaTeX characters -- but Pygments has already done that for us! I considered many times getting rid of fancyvrb entirely, but for a project maintained on my free time and in view of potential complications, this has low priority -- and for next few months I will surely not have time, I ended right now a period where I could do such things.

@n-peugnet
Copy link
Contributor

n-peugnet commented Mar 14, 2023

@jfbu Thank you for this very detailed answer. Sorry I could have checked the code myself before asking. I did some research of my own back when I made my version of this (that will probably be replaced by yours once I get to upgrade Sphinx), and I quickly understood that it was very complicated to do in LaTeX. The only beautiful solution I found was indeed based on soulutf8 package combined with Tikz and the code is still quite complicated.

@jfbu
Copy link
Contributor Author

jfbu commented Mar 14, 2023

@n-peugnet ah well of course I had forgotten the more modern stuff which uses TikZ ability and multiple passes to put absolute positional marks on the page and then add graphical layers on next run. I am not sure this works also with platex, and I saw problem reports with xetex from 2016 circa, perhaps solved since (pdftex has built-in such things \pdfsavepos/\pdflastxpos/\pdflastypos and one could use that for simple-minded tasks, not sure if TikZ pdftex graphics driver builds upon that, and I do not know what it does for dvipdfmx driver).

The tikzmark package has a highlighting library, documented starting on page 17 of its pdf documentation, which seems to implement exactly the naive idea one could have about positioning a start and an end, and interpolating. However, you already point out to a more advanced method indeed based upon tikzmark but in combination with soul. Why they have to use soul may have to do with allowing contents of varying height, or allowing pagebreaks. But using soul adds its intrinsic limitations.

About LuaTeX, I should have digged a bit more, there is the lua-ul package whose description is:

This package provides underlining, strikethough, and highlighting using features in LuaLaTeX which avoid the restrictions imposed by other methods. In particular, kerning is not affected, the underlined text can use arbitrary commands, hyphenation works etc.
The package requires LuaTeX version ≥ 1.12.0.

The important part here is: the underlined text can use arbitrary commands.

However I can not engage into LuaLaTeX only code here at Sphinx. (assuming it is possible to achieve what we want with it).

I think though, I can provide an experimental \sphinxbreakablebox which will simply attempt to grab character per character and insert breaking points in-between. This can also add data to display some special sign at a line break as for codelines. As I said above, similar sthings are already done by Sphinx in the bowels of sphinxlatexliterals.sty. I can try to support nested mark-up by making simplifying assumptions about the encountered commands, not sure if I can invest the time in reviewing all possible Sphinx produced mark-up from e.g. LaTeX escapes.

The last two days I completed and finished my on-going refactoring of Sphinx LaTeX internals with adding support for box-decoration-break=slice to admonitions and topic directives. Doing this horizontally is only a variant... once the character per character split is achieved. In the "vertical" case, this is much different as package framed has used TeX page building behind the scenes to break the input into large rectangular rendered boxes, and the Sphinx code only has to wrap these boxes in suitable decoration; for the horizontal case, the big problem is to know where TeX will horizontally break, but at the stage when this gets done, material is split into horizontal lines and it is about impossible to dissect them at macro level; the soul package innards force TeX to apply its line-breaking algorithm in a vertical box of minuscule 1/65536 TeX pt width, thus TeX applies fully all possibe hyphenation, then soul dissects this vertical box into its horizontal components which hopefully more or less represent each one character, but there are a lot of complications to recover kerning etc...

@jfbu
Copy link
Contributor Author

jfbu commented Mar 14, 2023

@n-peugnet I have implemented an experimental breakable box. Maybe I will include this as something to use at your own risk. From previous experience with using many small boxes one next to the other, there may be problems with long documents of pdf color stack.

  • I have to add a strut to each character to equalize the heights
  • Unfortunately I can not show the result for rounded boxes, due to an issue with pict2e when stroking a zero width path, there is still some visible alias on screen; I had already seen this problem and I am not sure what is its origin. So, inhibiting the right border of first stuff does not work if the other corners are rounded, and same for last character. In-between stuff use the "rectangle" routine anyhow.
  • I added support for UTF-8 and even for input with some macros inside. To test I inserted manually an extra \textit to get the second screenshot below. Supported macros are only of the `\text...̀ type, i.e. those which modifies font properties. Any macro doing some examination of its argument will be utterly broken.
  • Shadow is not supported if on the left; but ok if on right, as the screenshots demonstrate. A priori the code caters for inset shadow but as I did not test that part, it has probably some bug.
  • we can see some issues because there is no inter-small-boxes stretches, so it protrudes a bit unevenly in right margin
  • This is home made stuff with a few dozen lines, can not compete with approaches using the full TikZ apparatus or LuaLaTeX engine features...
  • If included in Sphinx, it will be left as "use at your own risk".
  • There may be some problems with some PDF viewers with antialiasing effetc of adjacent boxes. The shadows here insert some "glueing" which may help counteract such a problem. I used evince on Ubuntu 20.04 for this.

Example of output:

Capture d’écran du 2023-03-14 19-59-19

Capture d’écran du 2023-03-14 20-06-18

index.rst:

TEST
----

aaaa bbbb some text :guilabel:`some very œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù
éèàù éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù
éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù
œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç
éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù
éèàù éèàù éèàù long guilabel` This was a very very long guitlabel. Did it wrap correctly?

conf.py:

latex_elements = {
    'preamble': r"""
  \protected\def\sphinxguilabel#1{%
    \sphinxbreakablebox[% commented-out options are the default from sphinx.sty
                        % border-width=\fboxrule,
                        % padding=\fboxsep,
                        % border-radius=\fboxsep,
                        % border-TeXcolor={RGB}{32,32,32},%  default VerbatimBorderColor
                        % background-TeXcolor={gray}{0.95},% default VerbatimColor
                        % Now some extra settings:
                        border-radius=0pt,%  (needed currently due to an issue with pict2e;
                                          %   even setting width to 0pt, the lateral border
                                          %   is seen. So the start and end, if using the
                                          %   "rounded" routine will have an annoying extra border
                                          %   right where we don't want it)
                        border-width=1.5pt,
                        box-shadow=2pt 2pt,
                        box-shadow-TeXcolor=gray!50]{#1}}
"""
}

The LaTeX with an extra \textit, only as proof of concept. But the way it is implemented is very fragile. The main problem is that the 2-argument macro \sphinxhref will cause outrageous breakage. Not sure if it can end up there anyhow.

\sphinxAtStartPar
aaaa bbbb some text \sphinxguilabel{some very œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù
éèàù éèàù \textit{œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù
éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù
œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç
éèàù éèàù éèàù éèàù} œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù éèàù éèàù éèàù œîôêç éèàù
éèàù éèàù éèàù long guilabel} This was a very very long guitlabel. Did it wrap correctly?

I tested only UTF-8 with some diacritics useful in my mother tongue.

If you want to test it at your locale you should checkout the wip branch https://github.com/jfbu/sphinx/tree/wip_breakable_sphinxbox. The commit is jfbu@e8efd18

@jfbu
Copy link
Contributor Author

jfbu commented Mar 15, 2023

Merge of master into my workbranch wip_breakable_sphinxbox has allowed "breakablebox" to support rounded corners.

Capture d’écran du 2023-03-15 18-35-07

But the -one-box-per-character things induces aliasing artifacts at box junctures at least in my evince viewer at some zoom levels. One sees them above. I am not sure if they come from some minuscule differences in coordinates, but many many years ago I experimented with such problems in a context where one was sure all coordinates computed by TeX where perfectly identical from one rectangle to the adjacent one. Then perhaps something happens when converting to PostScript or PDF internals. Typically one sees some fine border but when zooming it sometimes disappear or reappear but never changes size on screen.

Personnaly I would prefer occasional problem with a non-breaking box than this. After some polishing I might merge it though, but will not consider this as a feature to be maintained at all costs.

There is a big difference between the user point of view who wants things done and the maintainer point of view: already Sphinx for many years allows a lot of LaTeX customization such as using the full TikZ for such \sphinxguilabel thing (it is much more difficult to plug-in externalities into for example code-blocks support code). And user does not care if that adds immense dependency and multiplies par 10 the build time and perhaps limit to only LuaLaTeX. But for maintainer it is an altogether different business...

Merge of master allows also varying border width also for rounded boxes:
Capture d’écran du 2023-03-15 18-52-10

@n-peugnet
Copy link
Contributor

@jfbu:

This is very impressive! I didn't expect you to do it when I posted my previous comment. I hope you didn't feel obliged to do it because of me and that it was a fun experiment!

Personnaly I would prefer occasional problem with a non-breaking box than this. After some polishing I might merge it though, but will not consider this as a feature to be maintained at all costs.

I completely agree with you on this. I was more suggesting the idea and linking to my findings to get your opinion and maybe give you some ideas. 🙂

@jfbu
Copy link
Contributor Author

jfbu commented Mar 15, 2023

@n-peugnet I do understand you feel a bit concerned in view of my recent frenzy of activities in Sphinx LaTeX these last few days and I can confirm that if I were to keep going like this for weeks, it would be time to get me to some psy counseling ;-) If I did it is of course because it was a fun experiment. I do feel a bit depressed though in view of the PDF viewers artefacts at box junctures, but I knew about this already. This only confirms that the kind of approach your findings already identified is definitely better: except in LuaTeX it is not possible to hook into some of TeX's paragraph building at macro level, and the only, and best, way is when graphics drivers provide the means to put absolute marks on the page, and then decorate on top of that. But... the only reasonable things, in view of having to support pdflatex, lualatex, xelatex and platex and uplatex, is to benefit from some existing framework, hence TikZ/pgf which does allow to produce very beautiful graphics but is really a big dependency. So in immediate future it can not be loaded by Sphinx in a systematic way. MetaPost could be another approach. But this may reinforce the LuaLaTeX, as same people who contributed to LuaTeX revived MetaPost these last years.

Now yesterday I had this fun experiment with breakable box, and indirectly this caused me to revisit my code from last year doing rounded boxes, and it motivated me to take out from it the use of "stroke" to draw the border, which was causing big hurdles to the breakable boxes, and repalce it all with only "fill path" operations. As it turns out this considerably reduced the complexity of the code (roughly a division by 2 of its length), but I hastily replaced all removed codelines by a lot of possibly repetitive code comments, as is my habit.

In total, your initial query about boxing for PDF output came at a time when I had only right then completed an effort to revive and revisit some work from last year to add rounded boxes to Sphinx. Turns out that the further effort for \sphinxbox did bring additional refactoring, unification, simplifications and enhancements to the code, and the "breakable" thing indirectly too for the last step today.

For the next few months, I will have to cater for completely different tasks, so this flood of changes has come to an end today. Only last step is to decide whether or not to add the experimental breakable box code which I will think about in next few days.

I added possibility of rounded boxes with very little overload last year, but they become default only at 6.0.0 and only for code-blocks. At 7.0.0 probably some defaults will be chosen for the admonitions to be less dumb than now, and in particular in case of page-breaks. Some years ago warning type notices did not break across pages; and the "shadow box" construct for topic directive did not either; now all of code-blocks, all admonitions, and topic directive all use the same underlying core code and have all the same customizability with only some legacy difference about whether border and padding go to page margin or say in text area.

Somewhere in my numerous comment I said it was very simple for users (knowledgeable in LaTeX) to hook TikZ or tcolorbox which uses it into stuff like \sphinxguilabel and much more difficult for diplay elements such as code-blocks. The recent series of patches to master branch, make it easier, and in fact since 5.1.0 and sphinxpackageboxes.sty file, it already was much more feasible than in earlier years. Indeed the architecture of Sphinx based upon framed.sty package, means that one only has to provide a "boxing macro", and forget about all matters of pagebreak which are taken care of automatically . When I tested \tcbox in place of the Sphinx own "rectangular" or "rounded" boxes the build time for Sphinx own document was very significantly increased, at least one, perhaps two orders of magnitude (I did not test again recently). So it is in fact not that difficult, perhaps at some point documentation can be provided to help end-users who want all the embellishments this allows, but it can not be made part of Sphinx core.

jfbu added a commit to jfbu/sphinx that referenced this pull request Mar 16, 2023
See discussion at sphinx-doc#11224

This is about a variant of Sphinx 6.2.0 \sphinxbox, which will break
across lines.  The way this is done is to split the input into
characters, handling encountered macros in various more or less apt
ways in passing and box them separately adapting the shape as first
and last must be handled especially.

Works with one-character input, even empty input.  See the file for
more explanations.

Decision has been made not to merge into Sphinx.

This commit puts the experimental code in a separate package in order
to make using it as easy as possible.  Simply grab the file, put
it at some place where TeX can find it or in your project with
latex_additional_files, and add \usepackage{sphinxbreakablebox} to
preamble.

Use at own risk.  It is not excluded that renamings of Sphinx
internals could at some future point break the file, but I will try to
sync with upstream as long as I contribute maintenance to Sphinx
LaTeX.
@jfbu
Copy link
Contributor Author

jfbu commented Mar 16, 2023

@n-peugnet I did some final wrap-up and my effort is at https://github.com/jfbu/sphinx/tree/wip_breakable_sphinxbox

To use, grab the file sphinxbreakablebox.sty and either inject it via latex_additional_files in your projects or put it in some place where LaTeX can find it, and in both cases add \usepackage{sphinxbreakablebox} to the 'preamble' entry of latex_elements.
But you must be using upcoming Sphinx 6.2.0 or, at this time, the current tip of master here.

More comments inside the file. This will not get merged in Sphinx core for time being, too hacky, too much workload to test it thoroughly in Sphinx context, and the problems with the PDF viewers artifacts.

jfbu added a commit to jfbu/sphinx that referenced this pull request Mar 16, 2023
See discussion at sphinx-doc#11224

This is about a variant of Sphinx 6.2.0 \sphinxbox, which will break
across lines.  The way this is done is to split the input into
characters, handling encountered macros in various more or less apt
ways in passing and box them separately adapting the shape as first
and last must be handled especially.

Works with one-character input, even empty input.  See the file for
more explanations.

Decision has been made not to merge into Sphinx.

This commit puts the experimental code in a separate package in order
to make using it as easy as possible.  Simply grab the file, put
it at some place where TeX can find it or in your project with
latex_additional_files, and add \usepackage{sphinxbreakablebox} to
preamble.

Use at own risk.  It is not excluded that renamings of Sphinx
internals could at some future point break the file, but I will try to
sync with upstream as long as I contribute maintenance to Sphinx
LaTeX.
jfbu added a commit to jfbu/sphinx that referenced this pull request Mar 20, 2023
See discussion at sphinx-doc#11224

This is about a variant of Sphinx 6.2.0 \sphinxbox, which will break
across lines.  The way this is done is to split the input into
characters, handling encountered macros in various more or less apt
ways in passing and box them separately adapting the shape as first
and last must be handled especially.

Works with one-character input, even empty input.  See the file for
more explanations.

Decision has been made not to merge into Sphinx.

This commit puts the experimental code in a separate package in order
to make using it as easy as possible.  Simply grab the file, put
it at some place where TeX can find it or in your project with
latex_additional_files, and add \usepackage{sphinxbreakablebox} to
preamble.

Use at own risk.  It is not excluded that renamings of Sphinx
internals could at some future point break the file, but I will try to
sync with upstream as long as I contribute maintenance to Sphinx
LaTeX.
@jfbu jfbu added the type:enhancement enhance or introduce a new feature label Mar 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
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.

None yet

2 participants