5

I'm writing a report where I use units inside a table. In few cases I need to use a range with units. But since I'm writing not in English (actually in Spanish) The result of a range using the preopisition to (asi in English) isn't useful for me. So, is there a way to write a range with \SIrange correctly in something different from English or should I forget it and do it manually?

A kind sort of MWE:

\documentclass{scrartcl}
\usepackage[usenames,dvipsnames,x11names,table]{xcolor}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}
%\usepackage{xspace}
%\usepackage{xkeyval}
\usepackage{array,multirow,tabularx,ragged2e,booktabs}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}
\newcolumntype{C}{>{\centering\arraybackslash\hspace{0pt}}X}
\usepackage{rotating}
\usepackage{colortbl}
\usepackage[per-mode=symbol]{siunitx}

\begin{document}
\begin{table}
\centering
\rowcolors{2}{}{lightgray!20}
\begin{tabularx}{4in}{@{\kern\tabcolsep} rYS[table-format=2.3] @{\kern\tabcolsep}}
\toprule
\multicolumn{2}{c}{Parámetros geométricos del modelo} & Valor \\ 
\midrule
$d$:  & diámetro & \SI{.59}{[\milli\metre]} \\
$ph$: & altura de la placa & \SI{3.5}{[\milli\metre]} \\
$l$:  & longitud o ancho de la placa & \SIrange{10}{50}{[\milli\metre]} \\
$L$:  & longitud del vaso & \SI{200}{[\milli\metre]} \\         
\bottomrule
\end{tabularx}                      
\caption[Parámetros geométricos]{Parámetros geométricos.}
\label{taula:pargeom}
\end{table}
\end{document}
  • Try \documentclass[spanish]{scrartcl} – Johannes_B Mar 1 '15 at 20:49
  • I'll be adding Spanish support to the next release :-) – Joseph Wright Mar 2 '15 at 22:45
5

For a lack of spanish at this time:

\documentclass[spanish]{scrartcl}
\usepackage{babel}
\usepackage[per-mode=symbol]{siunitx}
\ExplSyntaxOn
\providetranslation [ to = Spanish ]
{ to~(numerical~range) } { iraultza }%substitute the right word here
\ExplSyntaxOff

\begin{document}
        \SIrange{10}{50}{\milli\metre}
\end{document}

siunitx works closely with package translator. You can contribute by translating other strings and bring it to the project.

  • 2
    Indeed: last point is key! I can only cover languages I know reasonably well or have some contributions for :-) – Joseph Wright Mar 1 '15 at 21:31
  • 2
    @JosephWright Is there a list of words which need translation somewhere? – Ignasi Mar 2 '15 at 10:42
  • 1
    @Ignasi You need to define to (numerical range) in addition to the basics. If that one can be supplied I can add Spanish to the languages that siunitx knows. – Joseph Wright Mar 2 '15 at 19:30
  • 2
    @JosephWright In Spanish and Catalan to can be translated as a, like in Bernard's answer. – Ignasi Mar 2 '15 at 19:46
  • 1
    @Ignasi You mean a is the appropriate value? If so, I'll add. – Joseph Wright Mar 2 '15 at 19:47
4

The translator package should be loaded by siunitx if there were a spanish dictionary. There isn't so we have to use the tools provided by siunitx. I also suggest another layout for the table (2nd table):

\documentclass[spanish]{scrartcl}
\usepackage[usenames,dvipsnames,x11names,table]{xcolor}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[spanish]{babel}
\usepackage{array,multirow,tabularx,ragged2e,booktabs}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}
\newcolumntype{C}{>{\centering\arraybackslash\hspace{0pt}}X}
\usepackage{rotating}
\usepackage{colortbl}
\usepackage{siunitx}
\sisetup{per-mode=symbol,
table-space-text-post =\si{\milli\metre},
table-unit-alignment = left,
list-final-separator = { \translate{y} },
list-pair-separator = { \translate{y} },
range-phrase = { \translate{a} },
range-units =single
}

\begin{document}
\begin{table}[!h]
  \centering
  \rowcolors{2}{}{lightgray!20}
  \begin{tabularx}{4in}{@{\kern\tabcolsep} rYS[table-format=1.2] @{\kern\tabcolsep}}
    \toprule
    \multicolumn{2}{c}{Parámetros geométricos del modelo} & Valor \\
    \midrule
    $d$: & diámetro & .59\si{\,[\milli\metre]} \\
    $ph$: & altura de la placa & 3.5\si{\,[\milli\metre]} \\
    $l$: & longitud o ancho de la placa & {\SIrange{10}{50}{[\milli\metre]}} \\
    $L$: & longitud del vaso & {\SI{200}{[\milli\metre]}} \\
    \bottomrule
  \end{tabularx}
  \caption[Parámetros geométricos]{Parámetros geométricos.}
  \label{taula:pargeom}
\end{table}
\vskip3ex
\begin{table}[!h]
  \centering
  \rowcolors{2}{}{lightgray!20}
  \begin{tabularx}{4in}{@{\kern\tabcolsep} rYS[table-format=1.2] @{\kern\tabcolsep}}
    \toprule
    \multicolumn{2}{c}{Parámetros geométricos del modelo} & Valor\, [\si{\milli\metre}]\\
    \midrule
    $d$: & diámetro & .59 \\
    $ph$: & altura de la placa & 3.5 \\
    $l$: & longitud o ancho de la placa & {\numrange{10}{50}} \\
    $L$: & longitud del vaso & {200} \\
    \bottomrule
  \end{tabularx}
  \caption[Parámetros geométricos]{Parámetros geométricos.}
  \label{taula:pargeom}
\end{table}
\end{document} 

enter image description here

  • Great answer!!! I didnt' knew that package translator. About the table, is a good suggestion but my real tables have different units so I don't add it to the head. – Iraultza Belaustegigoitia Mar 4 '15 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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