Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am preparing a paper for Elsevier, then I used elsart document class. Tables are centered, but their captions are not centered. How can I solve this problem?

This is my code:

\documentclass{elsart}    
\usepackage{multirow}    
\usepackage{rotating}

\begin{document}    
\begin{table}[h!]    
\caption{....}    
\centering

\scalebox{1.5}{

\begin{tabular}{cc|c|c|c|c|c|c|c|l}

...

...

...

\end{tabular}}    
\label{tab:tab1}    
\end{table}

\end{document}

I'll be glad if someone help me.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

As Gonzalo Medina has commented, consider to switch to elsarticle.cls. That said, here's a hack that adds \centering to elsart's \@maketablecaption:

\documentclass{elsart}

\makeatletter
\long\def\@maketablecaption#1#2{\@tablecaptionsize
    \global \@minipagefalse
%    \hbox to \hsize{\parbox[t]{\hsize}{#1 \\ #2}}}% DELETED
    \hbox to \hsize{\parbox[t]{\hsize}{\centering #1 \\ #2}}}% ADDED

\makeatother

\begin{document}

\begin{table}
\caption{A caption}
\centering
(Tabular content)
\end{table}

\end{document}

enter image description here

share|improve this answer
    
Thank you so much, your answer was so useful for my problem. and as you and Gonzalo mentioned, I am trying to switch to "elsarticle" class. regards, Mohammad. –  Mohammad May 17 '12 at 16:00
    
@Mohammad You can only accept one answer, but you can (additionally) upvote every helpful one. ;-) –  lockstep May 17 '12 at 16:02

You should consider using the improved elsarticle document class instead; this is what Elsevier says about elsart and elsarticle:

Elsevier's previous document class for typeset articles, elsart.cls, is now over 10 years old. It has been replaced with this newly written document class elsarticle.cls, which has been developed for Elsevier by the leading TeX developer River Valley Technologies.

Using elsarticle, you will have centered one-line captions by default:

\documentclass{elsarticle}    
\usepackage{lipsum}% just to generate text for the example

\begin{document}    

\lipsum[2]
\begin{table}
  \centering
  \caption{test caption}    
  \begin{tabular}{ll}
  test & test
  \end{tabular}
  \label{tab:tab1}    
\end{table}

\end{document}

enter image description here

share|improve this answer
    
Hello dear Gonzalo, I change the document class to "elsarticle". But a problem stoped the compilation process. The problem is: "Undefined control sequence. \global\c@lastpage=13" this error is in AUX file. what can I do to it? –  Mohammad May 17 '12 at 15:56
    
my code is like below: \documentclass{elsarticle} \usepackage{subfigure} \usepackage{tikz} \usetikzlibrary{shapes,arrows} \usepackage{multirow} \usepackage{url} \usepackage{rotating} \usepackage{setspace} \doublespacing \begin{document} ............ \nocite{*} \bibliographystyle{IEEEtran} \bibliography{pose} \end{document} –  Mohammad May 17 '12 at 16:02
    
@Mohammad Try to delete all auxiliary files and compile again. If that doesn't help, ask a new (follow-up) question. –  lockstep May 17 '12 at 16:08
    
this problem is also solved by your answers. BUT now I lost my page style. according to my professor, my paper's pages should have a margin equal to 2.5cm from all the sides. and I used \oddsidemargin = 0cm \topmargin = 0cm \textheight = 25cm \textwidth = 16cm but now the pages height is not appropriate.(A4 page is 21*30 then I reduced 5cm from them and write 16*25 above). excuse me for my questions. I appreciate your kindness. –  Mohammad May 17 '12 at 16:26
    
@Mohammad: but you said you are writing a paper for Elsevier, right? Then you should use the format provided by Elsevier and who else but Elsevier knows how they want their papers formatted. I don't understand what your professor's opinion has to do with this. I don't want to sound rude nor unpolite... It's just that I don't understand why you want to change the Elsevier format when writing a paper for Elsevier! –  Gonzalo Medina May 17 '12 at 19:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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