0

Here is the MWE I mentioned for your reference.

If the table width exceeds the text width, the log file will contain the information Overfull \hbox (73.38211pt too wide). It is necessary to store this value 73.38211pt in one command. The width of the \wd\stubbox command is only stored at the points of the red highlighted boxes.

However, I need the total width of the table including overfilled text areas, as shown in the picture below.

Here is how to store the overfull value stored in one command. I would appreciate your advice.

MWE:

\documentclass{book}


\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{xpatch}
\usepackage{tabularx}
\usepackage[table]{xcolor}%
\usepackage{hyperref}
\usepackage{array}
\usepackage{dcolumn}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{showframe}
\newcolumntype{P}[1]{>{\raggedright\let\\}p{#1}}

\newcommand{\tablabel}[2]{\def\tablename{#1}\def\thetable{#2}}
\newcommand{\tableheading}[1]{{\fontsize{9.5pt}{11.5pt}\selectfont\textcolor{white}{\textbf{#1}}}}

\makeatletter
\gdef\tablenotesalign{\appto\TPTnoteSettings{\topsep0pt\leftmargin0pt\rightmargin0pt}}
\makeatother

\definecolor{titlecolor}{cmyk}{1,1,0,0.1}
\definecolor{tablegray}{cmyk}{0,0,0,0.10}

\renewcommand\fbox{\fcolorbox{red}{white}}

\newbox\stubbox
\newcommand{\stubwidth}[1]{%
\global\setbox\stubbox\hbox{#1}%
                \ifdim\wd\stubbox>\dimexpr\textwidth-1pt%
                   \fboxrule2pt\fbox{\hfill\hbox{#1}}%
                    \appto\TPTnoteSettings{\leftmargin0pt\rightmargin0pt}
                   \else%
                    \appto\TPTnoteSettings{\leftmargin0pt\rightmargin0pt}
                 #1\fi}

\begin{document}
    
\begin{table}[!b]
\tablabel{Table}{3.1}
\caption{Identifiers for the six sample datasets shown in this paper. For simplicity, all of them use the identity transformation (affine) matrix}\label{b-3548732-003-tab-001}\stubwidth{\tablenotesalign
\begin{threeparttable}

\rowcolors{1}{tablegray}{}\begin{tabularx}{\linewidth}{P{105pt}cccccccccccc}
\rowcolor{titlecolor}\tableheading{Distribution ID} & \tableheading{$\textit{\textbf{card}}$} & \tableheading{$\textit{\textbf{d}}$} & \tableheading{$\boldsymbol{sp}_{\textbf{1}}$} & \tableheading{$\boldsymbol{sp}_{\textbf{2}}$} & \tableheading{$\boldsymbol{sp}_{\textbf{3}}$} & \tableheading{$\boldsymbol{sp}_{\textbf{4}}$} & \tableheading{$\boldsymbol{a}_{\textbf{1}}$} & \tableheading{$\boldsymbol{a}_{\textbf{2}}$} & \tableheading{$\boldsymbol{a}_{\textbf{3}}$} & \tableheading{$\boldsymbol{a}_{\textbf{4}}$} & \tableheading{$\boldsymbol{a}_{\textbf{5}}$} & \tableheading{$\boldsymbol{a}_{\textbf{6}}$}\\
{Uniform (Figure \hyperref[b-3548732-003-fig-002]{\textcolor{titlecolor}{3.2}}a)} & {1000} & {2} & {0.02} & {0.02} &  &  & {1} & {0} & {0} & {0} & {1} & {0}\\
{{D}iagonal (Figure \hyperref[b-3548732-003-fig-002]{\textcolor{titlecolor}{3.2}}b)} & {1000} & {2} & {0.01} & {0.01} & {0.2} & {0.1} & {1} & {0} & {0} & {0} & {1} & {0}\\
{{G}aussian (Figure \hyperref[b-3548732-003-fig-002]{\textcolor{titlecolor}{3.2}}c)} & {2000} & {2} & {0.1} & {0.1} &  &  & {1} & {0} & {0} & {0} & {1} & {0}\\
{{S}ierpinski (Figure \hyperref[b-3548732-003-fig-003]{\textcolor{titlecolor}{3.3}}a)} & {1000} & {2} & {0.01} & {0.01} &  &  & {1} & {0} & {0} & {0} & {1} & {0}\\
{{B}it (Figure \hyperref[b-3548732-003-fig-003]{\textcolor{titlecolor}{3.3}}b)} & {5000} & {2} & {0.01} & {0.01} & {0.3} & {10} & {1} & {0} & {0} & {0} & {1} & {0}\\
{{P}arcel (Figure \hyperref[b-3548732-003-fig-003]{\textcolor{titlecolor}{3.3}}c)} & {1000} & {2} & {0.2} & {0.2} &  &  & {1} & {0} & {0} & {0} & {1} & {0}\\
\end{tabularx}

\end{threeparttable}}
\begin{tablenotes}
\item (1) the distribution ID $i\in[1,6]$ for six implemented distributions, (2) the model parameters depending on the chosen distribution.
\item (2) the model parameters depending on the chosen distribution, and
\item (3) a transformation matrix used later by the transformer. The first two components of the dataset descriptor, i.e., distribution ID and model parameters, are passed to the generator which generates the desired dataset. After that, the transformer applies an affine transformation on the generated data according to the third component of the dataset descriptor.
\end{tablenotes}
\end{table}

\end{document}

enter image description here

1

1 Answer 1

1

It is not entirely clear what is your problem and how the table should looks.

I answer is anticipates (based on loaded threeparttable) that:

  • table should preserve its natural width (determined by widths of columns)
  • caption width can bes equal to table width
  • width of table notes can be equal to table width
  • compilation had not to throw warnings \hbox (.... too wide)

To achieve above anticipated goals, I suggest to use changepage package by which macro is locally enlarged \textwidth, use talltblr˛of tabularraypackage instead ofthreeparttable`.

\documentclass{book}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document

\usepackage[font=small, labelfont=bf]{caption}
\usepackage[strict]{changepage}
\usepackage{xcolor}%
\definecolor{titlecolor}{cmyk}{1,1,0,0.1}
\definecolor{tablegray}{cmyk}{0,0,0,0.10}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\NewTblrTheme{tabcaptionof}%
{
    \DefTblrTemplate{caption}{default}%
    {\addtocounter{table}{-1}%
     \captionof{table}{\InsertTblrText{caption}}}
}
\SetTblrStyle{remark}{font=\footnotesize}
\SetTblrStyle{note}{font=\footnotesize}

\usepackage{hyperref}

\begin{document}
\setcounter{chapter}{3}

\lipsum[66]
    \begin{table}[htb]
    \captionsetup{skip=-0.5ex}
\begin{adjustwidth*}{}{-\marginparwidth}
\begin{talltblr}[
  theme = tabcaptionof,
caption = {Identifiers for the six sample datasets shown in this paper. For simplicity, all of them use the identity transformation (affine) matrix},
  label = {b-3548732-003-tab-001},
note{1} = {the distribution ID $i\in[1,6]$ for six implemented distributions, (2) the model parameters depending on the chosen distribution.},
note{2} = {the model parameters depending on the chosen distribution, and},
note{3} = {a transformation matrix used later by the transformer. The first two components of the dataset descriptor, i.e., distribution ID and model parameters, are passed to the generator which generates the desired dataset. After that, the transformer applies an affine transformation on the generated data according to the third component of the dataset descriptor.},
                ]{colspec = {l c c *{2}{S[table-format=1.2]} *{8}{Q[c]} },
                 row{1} = {guard, font=\bfseries, bg=titlecolor,fg=white},
                 cell{1}{2-Z} = {font=\bfseries\itshape},
                 row{odd[2]} = {bg=tablegray}
                 }
Distribution ID
    & card  &   &   sp$_1$
                    &   sp$_2$
                        &   sp$_3$
                            &   sp$_4$
                                &   a$_1$
                                    &   a$_2$
                                        &   a$_3$
                                            &   a$_4$
                                                &   a$_5$
                                                    &   a$_6$  \\
Uniform     (Figure \hyperref[b-3548732-003-fig-002]{\textcolor{titlecolor}{3.2}a}) 
    & 1000 & 2 & 0.02 & 0.02 &      &       & 1 & 0 & 0 & 0 & 1 & 0     \\
Diagonal    (Figure \hyperref[b-3548732-003-fig-002]{\textcolor{titlecolor}{3.2}b}) 
    & 1000 & 2 & 0.01 & 0.01 & 0.2  & 0.1   & 1 & 0 & 0 & 0 & 1 & 0     \\
Gaussian    (Figure \hyperref[b-3548732-003-fig-002]{\textcolor{titlecolor}{3.2}c})
    & 2000 & 2 & 0.1  & 0.1  &      &       & 1 & 0 & 0 & 0 & 1 & 0     \\
Sierpinski  (Figure \hyperref[b-3548732-003-fig-003]{\textcolor{titlecolor}{3.3}a})
    & 1000 & 2 & 0.01 & 0.01 &      &       & 1 & 0 & 0 & 0 & 1 & 0     \\
Bit         (Figure \hyperref[b-3548732-003-fig-003]{\textcolor{titlecolor}{3.3}b})
    & 5000 & 2 & 0.01 & 0.01 & 0.3  & 10    & 1 & 0 & 0 & 0 & 1 & 0     \\
Parcel     (Figure \hyperref[b-3548732-003-fig-003]{\textcolor{titlecolor}{3.3}c})
    & 1000 & 2 & 0.2  & 0.2  &      &       & 1 & 0 & 0 & 0 & 1 & 0     \\
\end{talltblr}
\end{adjustwidth*}
    \end{table}   
\lipsum[11]        
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .