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

missing line break in pysigline #8980

Closed
ndarmage opened this issue Mar 10, 2021 · 5 comments
Closed

missing line break in pysigline #8980

ndarmage opened this issue Mar 10, 2021 · 5 comments

Comments

@ndarmage
Copy link

ndarmage commented Mar 10, 2021

When producing the documentation for tex by make latexpdf with Sphinx v.3.5.2, I've noticed long lines extending out of the right page margin in the output pdf file with dictionaries used as class (or module) attributes. Minimal example:

mod_attr = {'key1': [i for i in range(10)], 'key2': 2, 'key3': 'ok'}
class example_class:
    "my class"
    cls_attr = {'key1': [i for i in range(100)], 'key2': 2, 'key3': 'key3'}
    def __init__(self, a):
        self.a = a

The problem is caused by the following line in the file sphinx.sty:
\newcommand{\pysigline}[1]{\item[{#1}]}
The optional argument of the item, that is the label, is typeset in horizontal mode, so that it is not possible to have line breaks. A possible solution is to use a parbox like:
\newcommand{\pysigline}[1]{\item[{\parbox[b]{\textwidth}{#1}}]}
which fixed my problem.

@jfbu
Copy link
Contributor

jfbu commented Mar 13, 2021

Thanks for report. This is related to #7241. Maybe #7241 (comment) will help you with better workaround for time being.

@jfbu
Copy link
Contributor

jfbu commented Mar 14, 2021

Fixed at 2934aac

@jfbu jfbu closed this as completed Mar 14, 2021
jfbu added a commit to jfbu/sphinx that referenced this issue Mar 15, 2021
Reason is that mark-up such as this:

   .. attribute:: state
                  state_machine

      The state and state machine which controls the parsing.  Used for
      ``nested_parse``.

generates two `\pysigline` each with `\phantomsection`. The latex code
to get good vertical spacing between label and its description, if label
``\parbox`` is multi-line, cause in this context the two (generally,
single-line) labels to be stacked vertically with no spacing.

This commit keeps the ``\parbox`` which fixes sphinx-doc#8980, but drops the
attempt to correct vertical distance to description, so as to not alter
the possibly more common use case of items with common description.
jfbu added a commit to jfbu/sphinx that referenced this issue Mar 15, 2021
Reason is that mark-up such as this:

   .. attribute:: state
                  state_machine

      The state and state machine which controls the parsing.  Used for
      ``nested_parse``.

generates two `\pysigline` each with `\phantomsection`. The latex code
to get good vertical spacing between label and its description, if label
``\parbox`` is multi-line, cause in this context the two (generally,
single-line) labels to be stacked vertically with no spacing.

This commit keeps the ``\parbox`` which fixes sphinx-doc#8980, but drops the
attempt to correct vertical distance to description, so as to not alter
the possibly more common use case of items with common description.
@ndarmage
Copy link
Author

Hello, this issue is marked as close.
I retrieved sphinx v.3.5.3 under Py 3.9.2.
Still the file .../sphinx/texinputs/sphinx.sty contains the old line :

\newcommand{\pysigline}[1]{\item[{#1}]}

which reproduces the bad behavior (line extending out of page margin) that started the same issue.

Thanks for your kind attention.
Best regards,

@jfbu
Copy link
Contributor

jfbu commented Apr 12, 2021 via email

@ndarmage
Copy link
Author

Thanks for your kind reply - c'est noté.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants