TransWikia.com

Centering table does not work with tbl macro

TeX - LaTeX Asked by Wahedsaw on April 22, 2021

I need to center the table but I am forced to use the following macro:

deftbl#1#2#3{%
globalsetboxtabcapboxvbox{#1}%
globalsetboxtabboxhbox{#2}%
globalsetboxtabnoteboxvbox{#3}%
noindentvbox{%
tablemovetextwidth%
advancetablemove-wdtabbox%
dividetablemove2%
%hspace*{tablemove}
vbox{%
hsizewdtabbox%
#1%
#2%
#3}}}

The macro do not allow me to center the table. I used centering and it did not work (not exactly center). I used makebox[textwidth][c]{ around the tabular but not exactly centered. What modifications (or deletion) I need to do in the macro to get the whole table centered.

Here is the whole code snippets:

documentclass{article}
%usepackage{chngcntr}
usepackage{amsmath}
usepackage{multirow}
usepackage{graphicx}
usepackage{natbib}
usepackage[hidelinks,colorlinks=true,linkcolor=blue,citecolor=blue,urlcolor=blue]{hyperref} % to include link for every
%usepackage{hyperref}
usepackage[extra]{tipa}
usepackage{blindtext}

ifpdf%
usepackage{epstopdf}%
else%
fi

makeatletter
newboxtabcapbox
newboxtabbox
newboxtabnotebox
newdimentablemove
newdimensidetskipsidetskip=0pt%
newdimensideverticalskipsideverticalskip=0pt
newififUnNumtableglobalUnNumtablefalse
newskiptablenumcapsep
newififUnNumtableglobalUnNumtablefalse

renewcommand{sfdefault}{phv}%

newenvironment{tabnote}{@partabnotefontvphantom{y}vskip-1pt}
    {@par}

deftablefont{fontfamily{sfdefault}fontsize{7.75}{9}selectfont}%
deftablecaptionfont{fontfamily{sfdefault}fontsize{7.75}{9}selectfont}%
deftablecaptwofont{fontfamily{sfdefault}fontsize{7.8}{9}selectfont}%
deftablecaptionnumfont{fontsize{7.75}{9}fontfamily{sfdefault}fontseries{sb}fontshape{n}selectfont}%
defTCHfont{fontfamily{sfdefault}fontsize{7.5}{9}selectfont}%
defTSCHfont{}%
deftabnotefont{fontfamily{sfdefault}fontsize{6.51}{8}selectfont}% use plus 1fill if needed
%% Long-Table
defLTtablecaptionfont{fontfamily{sfdefault}fontsize{7.5}{9}selectfont}%
defLTtablenotefont{fontfamily{sfdefault}fontsize{7.5}{9}selectfont}%




deftbl#1#2#3{%
globalsetboxtabcapboxvbox{#1}%
addtocounter{table}{-1}%
globalsetboxtabboxhbox{#2}%
globalsetboxtabnoteboxvbox{#3}%
noindentvbox{%
tablemovetextwidth%
advancetablemove-wdtabbox%
dividetablemove2%
%hspace*{tablemove}
vbox{%
hsizewdtabbox%
#1%
#2%
#3}}}

def@maketablecaption#1#2{
setboxtabcapboxvbox{{tablecaptionfontifunnumtableelsenoindent{tablecaptionnumfont#1}fi{tablecaptionnumfont}hskiptablenumcapsep#2vphantom{y}par}}
%ifdimwdtabcapbox<textwidth
ifdimhttabcapbox<19pt
%centerlast
{tablecaptionfontifunnumtableelsenoindent{tablecaptionnumfont#1}fi{tablecaptionnumfont}hskiptablenumcapsep#2vphantom{y}vskip.8pt}globalunnumtablefalse%
else
{tablecaptionfontifunnumtableelsenoindent{tablecaptionnumfont#1}fi{tablecaptionnumfont}hskiptablenumcapsep#2vphantom{y}vskip.8pt}globalunnumtablefalse%
fi}

begin{document}

blindtext

begin{table}[h!]

  tbl{caption{label{tab:ArabicDialects} Arabic dialects covered in our study.}}
 {begin{minipage}{25pc}
 makebox[textwidth][c]{
    begin{tabular}{@{extracolsep{fill}}p{0.25textwidth}p{0.21textwidth}}
    hline
    Arabic dialect & Abbreviation 
    hline
     Apple & 12  
     Android  &  20
     Swift &  33
     Google &  11
     Yahoo &  11
     Altavista &  23
     HP &  45
    hline
    end{tabular}}
  end{minipage}}
  {begin{tabnote}
  end{tabnote}}
end{table}


end{document}

the tbl macro is part of the journal class. Only change documentclass{article} to documentclass{Jclass}. You may face problems as the class is not compatible with recent LaTeX 2e-kernels but can be solved as explained here.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP