我需要将表格置于中央但我不得不使用以下宏:
\def\tbl#1#2#3{%
\global\setbox\tabcapbox\vbox{#1}%
\global\setbox\tabbox\hbox{#2}%
\global\setbox\tabnotebox\vbox{#3}%
\noindent\vbox{%
\tablemove\textwidth%
\advance\tablemove-\wd\tabbox%
\divide\tablemove2%
%\hspace*{\tablemove}
\vbox{%
\hsize\wd\tabbox%
#1%
#2%
#3}}}
宏不允许我将表格居中。我用过\centering
,但不起作用(不是完全居中)。我makebox[\textwidth][c]{
在表格周围使用了它,但没有完全居中。我需要在宏中进行哪些修改(或删除)才能使整个表格居中。
以下是整个代码片段:
\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
\newbox\tabcapbox
\newbox\tabbox
\newbox\tabnotebox
\newdimen\tablemove
\newdimen\sidetskip\sidetskip=0pt%
\newdimen\sideverticalskip\sideverticalskip=0pt
\newif\ifUnNumtable\global\UnNumtablefalse
\newskip\tablenumcapsep
\newif\ifUnNumtable\global\UnNumtablefalse
\renewcommand{\sfdefault}{phv}%
\newenvironment{tabnote}{\@par\tabnotefont\vphantom{y}\vskip-1pt}
{\@par}
\def\tablefont{\fontfamily{\sfdefault}\fontsize{7.75}{9}\selectfont}%
\def\tablecaptionfont{\fontfamily{\sfdefault}\fontsize{7.75}{9}\selectfont}%
\def\tablecaptwofont{\fontfamily{\sfdefault}\fontsize{7.8}{9}\selectfont}%
\def\tablecaptionnumfont{\fontsize{7.75}{9}\fontfamily{\sfdefault}\fontseries{sb}\fontshape{n}\selectfont}%
\def\TCHfont{\fontfamily{\sfdefault}\fontsize{7.5}{9}\selectfont}%
\def\TSCHfont{}%
\def\tabnotefont{\fontfamily{\sfdefault}\fontsize{6.51}{8}\selectfont}% use plus 1fill if needed
%% Long-Table
\def\LTtablecaptionfont{\fontfamily{\sfdefault}\fontsize{7.5}{9}\selectfont}%
\def\LTtablenotefont{\fontfamily{\sfdefault}\fontsize{7.5}{9}\selectfont}%
\def\tbl#1#2#3{%
\global\setbox\tabcapbox\vbox{#1}%
\addtocounter{table}{-1}%
\global\setbox\tabbox\hbox{#2}%
\global\setbox\tabnotebox\vbox{#3}%
\noindent\vbox{%
\tablemove\textwidth%
\advance\tablemove-\wd\tabbox%
\divide\tablemove2%
%\hspace*{\tablemove}
\vbox{%
\hsize\wd\tabbox%
#1%
#2%
#3}}}
\def\@maketablecaption#1#2{
\setbox\tabcapbox\vbox{{\tablecaptionfont\ifunnumtable\else\noindent{\tablecaptionnumfont#1}\fi{\tablecaptionnumfont}\hskip\tablenumcapsep#2\vphantom{y}\par}}
%\ifdim\wd\tabcapbox<\textwidth
\ifdim\ht\tabcapbox<19pt
%\centerlast
{\tablecaptionfont\ifunnumtable\else\noindent{\tablecaptionnumfont#1}\fi{\tablecaptionnumfont}\hskip\tablenumcapsep#2\vphantom{y}\vskip.8pt}\global\unnumtablefalse%
\else
{\tablecaptionfont\ifunnumtable\else\noindent{\tablecaptionnumfont#1}\fi{\tablecaptionnumfont}\hskip\tablenumcapsep#2\vphantom{y}\vskip.8pt}\global\unnumtablefalse%
\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.25\textwidth}p{0.21\textwidth}}
\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}
\tbl 宏是期刊类。只需将 \documentclass{article} 更改为 \documentclass{Jclass}。您可能会遇到问题,因为该类与最近的 LaTeX 2e 内核不兼容,但可以按如下方式解决这里解释。