Skip to content

Tabs items shouldn't be rendered as they are in LaTeX output #218

Open

Description

@dbitouze

Context

Currently, tabs such as:

.. tab-set::

    .. tab-item:: Label1

                  Content 1

    .. tab-item:: Label2

                  Content 2

are converted for the PDF's LaTeX output into the following .tex code:

\begin{sphinxuseclass}{sd-tab-set}
\begin{sphinxuseclass}{sd-tab-item}\subsubsection*{Label1}

\begin{sphinxuseclass}{sd-tab-content}
\sphinxAtStartPar
Content 1

\end{sphinxuseclass}
\end{sphinxuseclass}
\begin{sphinxuseclass}{sd-tab-item}\subsubsection*{Label2}

\begin{sphinxuseclass}{sd-tab-content}
\sphinxAtStartPar
Content 2

\end{sphinxuseclass}
\end{sphinxuseclass}
\end{sphinxuseclass}

This solution is sub-optimal because it introduces a level of structure (sub-sub-section) that may not be consistent with the context.

Proposal

Something such as what results from a definition list would be much better:

\begin{description}
\sphinxlineitem{Label1}
\sphinxAtStartPar
Content 1

\sphinxlineitem{Label2}
\sphinxAtStartPar
Content 2

\end{description}

Tasks and updates

No response

Activity

  1. added
    enhancement
    on Aug 27, 2024
  2. jfbu commented on Aug 27, 2024

    @jfbu

    @dbitouze I did not investigate where the \subsubsection* mark-up originates but defining appropriately the sphinxclasssd-tab-set, sphinxclasssd-tab-item and sphinxclasssd-tab-content LaTeX environment could transmogrify the mark-up you show into the one you wish.

    edited to do s/sphinx/sphinxclass/ sorry

  3. jfbu commented on Aug 27, 2024

    @jfbu

    I tried with

    % Support **experimental** pour les tab-set de sphinx-design
    % cf https://github.com/executablebooks/sphinx-design/issues/218
    % ATTENTION C'EST FRAGILE CAR IL NE FAUT PAS QUE LE MARK-UP LATEX DE
    % sphinx-design CHANGE (surtout pour sd-tab-item)
    \newenvironment{sphinxclasssd-tab-set}{\begin{description}}{\end{description}}
    \newenvironment{sphinxclasssd-tab-item}[3]{\item[#3]\leavevmode}{}
    % pas besoin pour le moment de définir sphinxsd-tab-content

    in the preamble and it gives an acceptable result. The above has been tested with success on a big project, now it may not be at all a sufficient test as that project might have been using sphinx-design tab-set always the same way. About the \leavevmode the contents were often code-blocks and for some reason I needed it to avoid overlap in the output (that may be an upstream Sphinx issue, not sure, to be checked at later date).

  4. jfbu commented on Aug 28, 2024

    @jfbu

    @dbitouze I should probably have proposed

    \newenvironment{sphinxclasssd-tab-item}[3]{\sphinxlineitem{#3}}{}

    following more closely your initial advice with \sphinxlineitem.

    I think \sphinxlineitem main purpose is to handle situations with a label but no contents, which may not be probable here, but it also avoids collision with a literal block as content, so no \leavevmode addition is needed. Besides this is indeed the mark-up produced by Sphinx from

    Term
     ::
    
       hello

    which gives

    \begin{description}
    \sphinxlineitem{Term}
    \begin{sphinxVerbatim}[commandchars=\\\{\}]
    \PYG{n}{hello}
    \end{sphinxVerbatim}
    
    \end{description}

    and renders correctly.

    You could use sphinxclasssd-tab-content to do something for example with \sphinxsetup to modify the characteristics of the rendered verbatim blocks which are the contents, style them especially. But this could also be done already at sphinxclasssd-tab-item level. I don't know if multiple tab-content can appear in one tab-item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions