8000 Best approach to get a content-fitting colorbox with vertical partitioning? · Issue #314 · T-F-S/tcolorbox · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Best approach to get a content-fitting colorbox with vertical partitioning? #314

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

Closed
fmatter opened this issue May 24, 2025 · 2 comments
Closed

Comments

@fmatter
Copy link
fmatter commented May 24, 2025

I'd like to make the box fit the content, the content being a verb paradigm table, which obviously differs in width depending on the verb (hence the fitting). Below that I'd like to add the irrealis forms of the same verb, ie. a second table. And below that a simple list with some additional non-table forms.

Now it seems that neither the upper/lower part mechanism, nor subtitles work when using capture=hbox. Why is that? And what can I do to achieve something close to the desired result?

@muzimuzhi
Copy link
Contributor
muzimuzhi commented May 24, 2025

Now it seems that neither the upper/lower part mechanism, nor subtitles work when using capture=hbox. Why is that?

capture=hbox disables lower part, and \tcbsubtitle is more suited for capturing modes in which the resulting box has a pre-set width and accepts multi-paragraph content.

And what can I do to achieve something close to the desired result?

One way is to save each table in a box, then use the boxes in a tcolorbox (using the default capture=minipage) whose text width set to the max width of those boxes.

\documentclass{article}
\usepackage{tcolorbox}

\newsavebox{\myVerbBoxA}
\newsavebox{\myVerbBoxB}
\newsavebox{\myVerbBoxC}
\newlength{\myVerbWidth}
\newlength{\myVerbWidthX}

\NewDocumentCommand{\myVerbTable}{m m m}{%
  \sbox{\myVerbBoxA}{#1}%
  \sbox{\myVerbBoxB}{#2}%
  \sbox{\myVerbBoxC}{#3}%
  \setlength{\myVerbWidth}{\wd\myVerbBoxA}%
  \ifdim\myVerbWidth<\wd\myVerbBoxB
    \setlength{\myVerbWidth}{\wd\myVerbBoxB}%
  \fi
  \ifdim\myVerbWidth<\wd\myVerbBoxC
    \setlength{\myVerbWidth}{\wd\myVerbBoxC}%
  \fi
  \begin{tcolorbox}[text width=\myVerbWidth, title=First part]
    \usebox{\myVerbBoxA}
    \tcbsubtitle{Second part}
    \usebox{\myVerbBoxB}
    \tcbsubtitle{Third part}
    \usebox{\myVerbBoxC}
  \end{tcolorbox}
}

\begin{document}
\myVerbTable{Content}{more}{more \ldots}

\myVerbTable{\begin{tabular}{@{}ll@{}}
  a & a \\
  bb & bb \\
  ccc & ccc
\end{tabular}}{more}{looooong loooong loooong}
\end{document}

Image Image

BTW, more suited for Q&A forums like tex.stackexchange.com.

@fmatter
Copy link
Author
fmatter commented May 24, 2025

Duly noted, yes. Thank you very much, this is exactly what I needed.

@fmatter fmatter closed this as completed May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0