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

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

Open
dbitouze opened this issue Aug 27, 2024 · 3 comments
Open

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

dbitouze opened this issue Aug 27, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@dbitouze
Copy link

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

@dbitouze dbitouze added the enhancement New feature or request label Aug 27, 2024
@jfbu
Copy link

jfbu commented Aug 27, 2024

@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

@jfbu
Copy link

jfbu commented Aug 27, 2024

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).

@jfbu
Copy link

jfbu commented Aug 28, 2024

@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
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants