8

I´m starting using cleveref package. I like it.

But now I´m typing in spanish and when \cref is pointing to a table I want that use the word "tabla" instead "cuadro", in the text.

When I type "is \cref{tab:a1}" I want obtain "is tabla 2" and NOT "is cuadro 2"

I tried with this lines

\renewcommand{\listtablename}{Índice de tablas}
\renewcommand{\tablename}{Tabla} 

but this only changes the word below the table, as you can see.

Here is a MWE:

\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{mathtools,amsmath,amssymb}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish]{cleveref}
\usepackage[spanish]{babel}


\begin{document}
\renewcommand{\listtablename}{Índice de tablas}
\renewcommand{\tablename}{Tabla} 

La \cref{tab:1a} es bonita(beautifull)\\

\begin{table}[h!]
\centering
\begin{tabular}[h!]{ccc}
\ $a$ & $b$ & $c$ \\
\hline 0 & 0 & 0 \\
\ 1 & 1 & label label-tab:1a \\
\end{tabular}
\caption{A subtable}\label{tab:1a}
\end{table}


\end{document} 
lockstep
  • 250,273
Mika Ike
  • 3,751

2 Answers2

8

First of all I think it's worth to read answer to question "¿Por qué spanish para babel dice cuadro en lugar de tabla?" (Why spanish babel says "cuadro" instead of "tabla"?) in FAQ-CervanTeX (FAQ from spanish users group).

And in case you still insist in changing this word, adding es-tabla option to babel will do it. With cleveref some more customization is needed as lockstep suggested but I think something like

\crefname{table}{\spanishtablename}{\spanishtablename}

could be better than a hardcoded solution.

Last comment if spanish is passed as option to documentclass, it will be automatically passed to babel and cleveref.

\documentclass[spanish]{article}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{mathtools,amsmath,amssymb}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[es-tabla]{babel}
\usepackage{cleveref}

\crefname{table}{\spanishtablename}{\spanishtablename}

\begin{document}

La \cref{tab:1a} es bonita (\emph{beautifull})\\

\begin{table}[h!]
\centering
\begin{tabular}[h!]{ccc}
\ $a$ & $b$ & $c$ \\
\hline 0 & 0 & 0 \\
\ 1 & 1 & label label-tab:1a \\
\end{tabular}
\caption{A subtable}\label{tab:1a}
\end{table}

\end{document}
Ignasi
  • 136,588
5

Add

\crefname{table}{tabla}{tablas}

to your example. See section 8.1.2 of the cleveref manual for details. Note that it is also good practice to load cleveref at the very end of the preamble.

lockstep
  • 250,273
  • is important type it after \begin{document} Thank you @lockstep – Mika Ike Jun 12 '14 at 13:31
  • 2
    @MikaIke General formatting changes should be done in the preamble. Note that, instead of redefining \tablename and \listtablename in the document body, you should do it in the preamble using \addto\captionsspanish; see http://tex.stackexchange.com/questions/82993/how-to-change-the-name-of-document-elements-like-figure-contents-bibliogr – lockstep Jun 12 '14 at 13:34
  • @lockstep I agree it should be in the preamble, but in my case it has no effect... on the other hand, inserting after \begin{document}, as suggested by @mika-ike, does has effect. Maybe my template is running something just before \begin{document} and re-re-defining for `cuadro'. I've tried to put \crefname inside \AtBeginDocument, but it also did not work. :-( – LEo Apr 06 '21 at 20:05
  • I've used \AfterEndPreamble{...} from the etoolbox package and added \AfterEndPreamble{\crefname{table}{tabla}{tablas}}. It worked fine. :-) – LEo Apr 28 '21 at 12:38