Scaling down tabularray #544
pravinbansal-pt
started this conversation in
Q&A
Replies: 1 comment 1 reply
-
An incomplete tricky attempt which only works for
\documentclass{article}
\usepackage{tabularray}
\ExplSyntaxOn
\cs_undefine:N \__tblr_halign_whole:Nn
\cs_new_protected:Npn \__tblr_halign_whole:Nn #1 #2
{
\noindent
\fp_compare:nNnF { \l__tblr_scale_fp } = { \c_one_fp }
{ \box_scale:Nnn #1 { \l__tblr_scale_fp } { \l__tblr_scale_fp } }
\hbox_to_wd:nn { \linewidth }
{
\tl_if_eq:nnF {#2} {l} { \hfil }
\box_use:N #1
\tl_if_eq:nnF {#2} {r} { \hfil }
}
}
\keys_define:nn { tblr }
{
% use leading underscore to denote it's not officially supported
_scale .fp_set:N = \l__tblr_scale_fp
}
\DefTblrTemplate { caption } { _normal }
{
\hbox_set:Nn \l__tblr_caption_box
{
\UseTblrTemplate { caption-tag } { default }
\UseTblrTemplate { caption-sep } { default }
\UseTblrTemplate { caption-text } { default }
}
\dim_compare:nNnTF { \box_wd:N \l__tblr_caption_box } > { \hsize }
{
\UseTblrAlign { caption }
\UseTblrIndent { caption }
\hbox_set:Nn \l__tblr_caption_left_box
{
\UseTblrTemplate { caption-tag } { default }
\UseTblrTemplate { caption-sep } { default }
}
\hangindent = \box_wd:N \l__tblr_caption_left_box
\hangafter = 1
\UseTblrHang { caption }
\leavevmode
\hbox_unpack:N \l__tblr_caption_box
\par
}
{
\centering
\fp_compare:nNnF { \l__tblr_scale_fp } = { \c_one_fp }
{
\box_scale:Nnn \l__tblr_caption_box
{ 1/\l__tblr_scale_fp } { 1/\l__tblr_scale_fp }
}
\makebox [\hsize] [c] { \box_use:N \l__tblr_caption_box }
\par
}
}
\SetTblrTemplate { caption } { _normal }
\ExplSyntaxOff
\begin{document}
\SetTblrInner[longtblr]{_scale=1}
\begin{longtblr}[
caption = {A Long Long Long Long Long Long Long Table},
label = {tblr:test},
]{
colspec = {XXX}, width = 0.85\linewidth,
}
\hline
Head & Head & Head \\ \hline
Head & Head & Head \\ \hline
Alpha & Beta & Gamma
\end{longtblr}
\begin{longtblr}[
caption = {A Long Long Long Long Long Long Long Table},
label = {tblr:test},
]{
colspec = {XXX}, width = 0.85\linewidth,
_scale=.5
}
\hline
Head & Head & Head \\ \hline
Head & Head & Head \\ \hline
Alpha & Beta & Gamma
\end{longtblr}
\end{document} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to scale down a tabularray table without scaling down the caption. Currently:
Will scale the caption down as well the contents. Just wanting to scale down the contents. Previously possible with standard latex tables as the caption would sit outside of tabular and you could run the scalebox just on tabular.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions