如何将 siunitx 包本地化为西班牙语?

如何将 siunitx 包本地化为西班牙语?

我正在写一份报告,其中我在表格中使用了单位。在少数情况下,我需要使用带单位的范围。但由于我不是用英语写的(实际上是用西班牙语写的),所以使用介词 to(英语中的 asi)的范围的结果对我来说没用。那么,有没有办法用不同于\SIrange英语的语言正确地写出范围,或者我应该忘记它并手动完成?

一种 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}

答案1

由于目前缺少西班牙语:

\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与 包紧密配合translator。您可以通过翻译其他字符串做出贡献并将其带入项目。

答案2

translator如果有西班牙语词典,则应加载该包siunitx。没有,所以我们必须使用 siunitx 提供的工具。我还建议表格采用另一种布局(第二张表):

\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} 

在此处输入图片描述

相关内容