Search code examples
latexrenewcommand

How to rename tables?


I'm writing a paper in Spanish, and I need the name of my tables as "Tabla," not as "Cuadro" which is the current name. I used the command:

\renewcommand{\tablename}{Tabla} 

But it is not working, as nothing changes. I do not have any error when compiling, and the name of my table is still "Cuadro".

\documentclass[journal]{IEEEtran}
\usepackage[utf8]{inputenc}
\usepackage[spanish, english]{babel}
\usepackage{graphicx}
\usepackage{amsmath}
\spanishdecimal{.}

\begin{document}
\renewcommand{\tablename}{Tabla} 
\newcommand\Tstrut{\rule{0pt}{2.6ex}}        
\newcommand\Bstrut{\rule[-0.9ex]{0pt}{0pt}}  

    \begin{table}[h!]
    \begin{center}
    \caption{Title}
        \label{label1}
        \centering
        \begin{tabular}{c}
            \hline \rule[-1ex]{0pt}{2.5ex}something A \Tstrut\Bstrut\\ 
             \rule[-1ex]{0pt}{2.5ex} Something B \Tstrut\Bstrut \\ 
            \rule[-1ex]{0pt}{2.5ex}Something C\Tstrut\Bstrut  \\ 
            \hline 
        \end{tabular}
    \end{center}
\end{table} 
\end{document}

Solution

  • There is a special option es-tabla for the babel package.

    Some other points:

    • if the main language of your document is Spanish, this should be the last language loaded in the options of the babel package, e.g. after english

    • the floating specifier [h!] is almost a guarantee for bad image placement, better use something like [htbp]

    \documentclass[journal]{IEEEtran}
    \usepackage[utf8]{inputenc}
    \usepackage[english,spanish,es-tabla]{babel}
    \usepackage{graphicx}
    \usepackage{amsmath}
    \spanishdecimal{.}
    
    \newcommand\Tstrut{\rule{0pt}{2.6ex}}        
    \newcommand\Bstrut{\rule[-0.9ex]{0pt}{0pt}}  
    
    \begin{document}
    
    
    
    
    
        \begin{table}[htbp]
        \begin{center}
        \caption{Title}
            \label{label1}
            \centering
            \begin{tabular}{c}
                \hline \rule[-1ex]{0pt}{2.5ex}something A \Tstrut\Bstrut\\ 
                 \rule[-1ex]{0pt}{2.5ex} Something B \Tstrut\Bstrut \\ 
                \rule[-1ex]{0pt}{2.5ex}Something C\Tstrut\Bstrut  \\ 
                \hline 
            \end{tabular}
        \end{center}
    \end{table} 
    \end{document}
    

    enter image description here