2

I'm new at LaTeX, been using overleaf to write a paper. The first version was working, but I was asked to change the template to the specific of the Journal. I was able to addapt almost everything but the captions of the 2 - row tables (table*) and figures (figure*). No matter what I do, I can't align them to table and figure borders. They show up like this: enter image description here.

This template uses an .sty file to define the enviroments. I believe that is the problem, the code of the table environment in the .sty file is this:

% Floats 
\def\topfraction{.9}

\def\bottomfraction{.9}
\setcounter{topnumber}{4}
\setcounter{bottomnumber}{3}
\setcounter{totalnumber}{5}
\renewcommand\textfraction{.1}
\renewcommand\floatpagefraction{.9}
\setcounter{dbltopnumber}{2}
\renewcommand\dbltopfraction{.9}
\renewcommand\dblfloatpagefraction{.95}
\newdimen \FullWidth
\FullWidth=\textwidth

\newcolumntype{L}{@{\extracolsep{\fill}}l}
\newcolumntype{R}{@{\extracolsep{\fill}}r}
\newcolumntype{C}{@{\extracolsep{\fill}}c}

\cs_gset_eq:NN \thead  \toprule 
\cs_gset_eq:NN \endthead  \midrule 
\cs_gset_eq:NN \tabref  \ref 

\dim_new:N \l_tbl_width_dim
\dim_set:Nn \l_tbl_width_dim { \linewidth }

\cs_new:Npn \__make_tbl_caption:nn #1#2
{
  \l_tbl_align_tl
  \skip_vertical:N \l_tbl_abovecap_skip 
  % \bool_if:NTF \g_tbl_full_bool
  % { 
  %  \color{scolor!70}\rule{\FullWidth}{2pt}\normalcolor\\
  % } 
  % { \color{scolor!70}\rule{\tblwidth}{2pt}\normalcolor\\ }
  % \fboxsep=4pt
  % \colorbox{white}
  {\parbox{ \dimexpr(\l_tbl_width_dim)}
    {\rightskip=0pt\sffamily\small\textbf{\color{scolor}#1}\par#2\par\vskip4pt }}
  \skip_vertical:N \l_tbl_belowcap_skip
}

\keys_define:nn { cas / tbl }
{
  width     .dim_set:N   =  \l_tbl_width_dim ,
  pos       .tl_set:N    =  \l_tbl_pos_tl ,
  cols      .tl_set:N    =  \l_tbl_cols_tl ,
  align     .tl_set:N    =  \l_tbl_align_tl,
  abovecap  .skip_set:N  =  \l_tbl_abovecap_skip ,
  belowcap  .skip_set:N  =  \l_tbl_belowcap_skip ,
  abovetbl  .skip_set:N  =  \l_tbl_abovetbl_skip ,
  belowtbl  .skip_set:N  =  \l_tbl_belowtbl_skip ,
  full      .bool_gset:N =  \g_tbl_full_bool ,
  unknown   .code:n      = { 
                              \ifstrempty { #1 } 
                                 {
                                   \tl_set:Nn \l_fig_pos_tl { \l_keys_key_tl }
                                 } 
                                 {
                                   \l_keys_key_tl=#1
                                 }  
                           }  
}

\cs_set:Npn \__reset_tbl:
{
  \tl_set:Nx \l_tbl_pos_tl { t }
  \tl_set:Nx \l_tbl_cols_tl { 1 }
  \tl_set:Nn \l_tbl_align_tl { \centering }
  \skip_set:Nn \l_tbl_abovecap_skip { 6pt }
  \skip_set:Nn \l_tbl_belowcap_skip { 0pt }
  \skip_set:Nn \l_tbl_abovetbl_skip { 6pt }
  \skip_set:Nn \l_tbl_belowtbl_skip { 6pt }
  
}

\RenewDocumentEnvironment { table } { O{} }
{
  \__reset_tbl:
  \bool_gset_false:N \g_tbl_full_bool
  \dim_set:Nn \l_tbl_width_dim { \linewidth }
  \keys_set:nn { cas / tbl } { #1 }
  \csxdef{fps@table}{\l_tbl_pos_tl}
  \csgdef{tblwidth}{\dim_use:N \l_tbl_width_dim}
  \cs_set_eq:NN \@makecaption \__make_tbl_caption:nn 
  \@float{table}
  \l_tbl_align_tl
  \sffamily\small
}
{
\end@float                                                       
}

    
\RenewDocumentEnvironment { table* } { O{width=\FullWidth} }
  {
    \__reset_tbl:
    \bool_gset_true:N \g_tbl_full_bool
      \dim_set:Nn \l_tbl_width_dim { \FullWidth }
   \keys_set:nn { cas / tbl } { #1 }
    \csxdef{fps@table}{\l_tbl_pos_tl}
    \csgdef{tblwidth}{\dim_use:N \l_tbl_width_dim}
    \cs_set_eq:NN \@makecaption \__make_tbl_caption:nn 
    \@dblfloat{table}
     \l_tbl_align_tl
     \sffamily\small
 %    \leftskip=-\FullWidth
  }
  {
    \end@dblfloat                                                       
  }
  

And this is how I define the Table* in the main file:

   \begin{table*}[htpb]
\small
\caption{Filtration results for XG (1.05 and 2.10 ppb) and CMC (0.525, 1.05 and 2.10 ppb) formulations with 70.10 ppb CaCO$_3$ F.}
\label{tbl:Filt res polymer}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}llllll}
\hline
\textbf{Formulation}    & \multicolumn{2}{c}{\textbf{XG}}                                       & \multicolumn{3}{c}{\textbf{CMC}}                                                                           \\ 
\textbf{{[}ppb{]}}      & \multicolumn{1}{c}{\textbf{1.05}} & \multicolumn{1}{c}{\textbf{2.10}} & \multicolumn{1}{c}{\textbf{0.525}} & \multicolumn{1}{c}{\textbf{1.05}} & \multicolumn{1}{c}{\textbf{2.10}} \\ \hline
\textbf{V$_f$   {[}cm$^3${]}} & 93.77 \textpm\ 1.15                      & 51.43 \textpm\ 2.31                      & 100.77 \textpm\ 7.57                      & 54.10 \textpm\ 2.00                      & 23.10 \textpm\ 1.00                      \\
\textbf{m$_{wc}$   {[}g{]}}  & 57.78 \textpm\ 1.53                      & 35.45 \textpm\ 1.00                      & 94.05 \textpm\ 4.41                       & 58.45 \textpm\ 4.36                      & 19.78 \textpm\ 1.53                      \\
\textbf{m$_{dc}$   {[}g{]}}  & 26.00 \textpm\ 0.44                      & 15.27 \textpm\ 0.60                      & 49.20 \textpm\ 5.41                       & 26.40 \textpm\ 1.39                      & 08.13 \textpm\ 0.76                       \\
\textbf{M$_R$ {[}\%{]}}    & 45.03 \textpm\ 1.86                      & 43.10 \textpm\ 2.43                      & 52.26 \textpm\ 4.52                       & 45.21 \textpm\ 0.97                      & 41.08 \textpm\ 0.93                      \\
\textbf{th {[}mm{]}}    & 09.32 \textpm\ 0.23                       & 07.02 \textpm\ 0.15                       & 15.93 \textpm\ 0.29                       & 08.65 \textpm\ 0.18                       & 04.37 \textpm\ 0.52                       \\
\textbf{T$_{mc}$ {[}mm{]}} \citep{chenevert2001model} & 09.12 \textpm\ 0.38                       & 05.69 \textpm\ 0.26                       & 13.92 \textpm\ 0.71                       & 09.21 \textpm\ 0.77                       & 03.23 \textpm\ 0.23                       \\ \hline
\end{tabular*}
\end{table*}

Any tips on how I solve that?

4
  • 3
    Welcome to TeX.SE. Please tell us (a) which document class you employ and (b) whether you any packages that help modify the appearance of captions. – Mico Apr 7 at 18:44
  • 2
    Assuming you are using Elsevier's cas-dc class, you have to use Elsevier's special syntax for these: support.stmdocs.in/wiki/… In your case, changing the first line of your table* environment to \begin{table*}[width=\textwidth] should do the job. But without seeing a complete example it's hard to say for certain. – Paul Gessler Apr 7 at 19:10
  • @PaulGessler . Thank you. I am using Elsevier's cas-dc class. Your answer solved it. – Giovani Fritoli Apr 7 at 19:39
  • @Mico Thank you. I am using Elsevier's cas-dc class and added in my preamble the caption and subcaption packages. – Giovani Fritoli Apr 7 at 19:41
0

While we wait for your MWE (Minimal Working example, a small complete document) which reproduce your problem, see the following suggestion on how you can better design your table:

  • in preamble you need to load the following packages:
\documentclass[twocolumn]{cas-dc}
\usepackage{natbib}
% unknown part of your premble

\usepackage{amsmath}
\usepackage{array, booktabs, threeparttable}
\NewExpandableDocumentCommand\mcc{O{1}m}{\multicolumn{#1}{c}{#2}}
\usepackage[version=4]{mhchem}
\usepackage{siunitx}

%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}
  • document body with your table:
\begin{document}
   \begin{table*}[width=\textwidth] 
    \sisetup{table-format=4.2(3),
             separate-uncertainty}   
    \small
    \setlength\tabcolsep{0pt}
\begin{threeparttable}
    \caption{Filtration results for XG (1.05 and 2.10 ppb) and CMC (0.525, 1.05 and 2.10 ppb) formulations with 70.10 ppb \ce{CaCO3} F.}
    \label{tbl:Filt res polymer}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} >{$}l<{$} *{5}{S} }
    \toprule
\textbf{Formulation}  
    & \mcc[2]{\textbf{XG}}                                       
            & \mcc[3]{\textbf{CMC}}          \\
    \cmidrule{2-3}
    \cmidrule(l){4-6}
\textbf{[ppb]}      
    & \mcc{\textbf{1.05}} 
        & \mcc{\textbf{2.10}} 
            & \mcc{\textbf{0.525}} 
                & \mcc{\textbf{1.05}} 
                    & \mcc{\textbf{2.10}} \\ 
    \midrule
V_f\ [\si{\cubic\centi\metre}]
    & 93.77(115)    & 51.43(231)    & 100.77(757)   & 54.10(200)    & 23.10(100)    \\
m_{wc}\ [\si{\gram}]
    & 57.78(153)    & 35.45(100)    & 94.05(441)    & 58.45(436)    & 19.78(153)    \\
m_{dc}\ [\si{\gram}]
    & 26.00(44)     & 15.27(60)     & 49.20(541)    & 26.40(139)    & 08.13(76)     \\
M_R\ [\si{\%}]      
    & 45.03(186)    & 43.10(243)    & 52.26(452)    & 45.21(97)     & 41.08(93)     \\
\text{th}\ [\si{\milli\metre}]
    & 09.32(23)     & 07.02(15)     & 15.93(29)     & 08.65(18)     & 04.37(52)     \\
T_{mc}\ [\si{\milli\metre}]\tnote{*}  
    & 09.12(38)     & 05.69(26)     & 13.92(71)     & 09.21(77)     & 03.23(23)     \\ \bottomrule
\end{tabular*}
\begin{tablenotes}[flushleft]\small
\item[*]    cite Chenevert and Dewan 2001 reference
\end{tablenotes}
\end{threeparttable}
\end{table*}
\lipsum

% unknown part of article bibliography
\end{document}

If you merge both code fragments the result of compilation will be:

enter image description here

(red lines indicate page layout)

Answer can be completed after you provide MWE.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.