Skip to content

too much white space on top of captioned literal blocks in PDF output #2460

Closed

Description

@jfbu

There are currently three cumulated vertical whitespace in PDF output for literal blocks with caption:

  1. a \literalblockcaptiontopvspace which is half of baselineskip, typically 6pt,
  2. a \smallskip, typically 3pt
  3. a \abovecaptionskip coming from the caption itself, typically 10pt.

That makes for a total of about 20pt, this is a lot. Especially when the literal blocks is in an indented context.

Perhaps \literalblocktopvspace comes from a time when the caption was handled otherwise ? (perhaps put at the end of the code-blocks ?). I propose to suppress both \literalblockcaptiontopvspace and \smallskip (from the Verbatim code; it would be kept only for non-captioned case).

If this done the

\newcommand{\literalblockneedspace}{5\baselineskip}

should use a smaller setting too, say 4\baselineskip.

Activity

  1. added 2 commits that reference this issue on Apr 20, 2016
    e9774db
    94de4d6
  2. added a commit that references this issue on Apr 25, 2016
    b2b8fa4
  3. jfbu commented on Apr 25, 2016

    @jfbu
    ContributorAuthor

    For comparison here is output from current stable branch compared to output from current https://github.com/jfbu/sphinx/tree/latex_less_space_above_codecaptions (not yet a PR, as I am not sure myself if really better).

    Current stable:

    testtopspace 5

    Now, with current https://github.com/jfbu/sphinx/tree/latex_less_space_above_codecaptions

    testtopspace-fix 5

    Source:

    .. testtopspace documentation master file, created by
       sphinx-quickstart on Wed Apr 20 20:10:22 2016.
       You can adapt this file completely to your liking, but it should at least
       contain the root `toctree` directive.
    
    Welcome to testtopspace's documentation!
    ========================================
    
    .. toctree::
       :maxdepth: 2
    
    
    Section
    -------
    
    
    A first listing with a caption.
    
    .. code-block:: python3
       :caption: Python 3.5 sample A
       :linenos:
    
        >>> 2 + 2
        4
        >>> 50 - 5*6
        20
    
    A second listing but without a caption.
    
    .. code-block:: python
       :linenos:
    
        >>> (50 - 5*6) / 4
        5.0
        >>> 8 / 5  # division always returns a floating point number
        1.6
    
    ..
    
       This third listing is quoted and with a caption
    
       .. code-block:: python
          :caption: Python 3.5 sample C
          :linenos:
    
           >>> 2 + 2
           4
           >>> 50 - 5*6
           20
    
       The fourth and fifth listings are in a list.
    
       * .. code-block:: python
             :caption: Python 3.5 sample D
             :linenos:
    
              >>> (50 - 5*6) / 4
              5.0
              >>> 8 / 5  # division always returns a floating point number
              1.6
    
       * .. code-block:: python
             :linenos:
             :caption: Python 3.5 sample E
    
              >>> (50 - 5*6) / 4
              5.0
              >>> 8 / 5  # division always returns a floating point number
              1.6
    
  4. tk0miya commented on Apr 27, 2016

    @tk0miya
    Member

    LGTM! Go ahead :-)

  5. added this to the 1.4.2 milestone on Apr 27, 2016
  6. added a commit that references this issue on Apr 27, 2016
  7. jfbu commented on Apr 27, 2016

    @jfbu
    ContributorAuthor

    fixed by b2b8fa4

  8. locked as resolved and limited conversation to collaborators on Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions