1

By default, the decimal separator of the tasks package is the period. In French, it is the comma. How to make the following code display a comma while keeping the period in the source code?

In other words, the following code

\documentclass{article}
\usepackage{tasks}
\usepackage[french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
\begin{tasks}[item-format=\ensuremath](1)
\task 0.6\times0.7=0.42
\task 0.05\times0.1=0.005
\task 0.07\times0.08=0.0056
\end{tasks}
\end{document}

looks like this:

avec virgule

and not as this:

sans virgule

AndréC
  • 24,137
  • Fun. If I add \usepackage[spanish]{babel} (and T1 fonts, ça va sans dire), it works. But with [french], it doesn't, maybe there some option... – Rmano May 26 '23 at 16:52
  • Not in French with this code \usepackage[french]{babel} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} I updated the question code. – AndréC May 26 '23 at 16:58
  • Yes, I know. But if you try spanish you'll have your comma, so there should be some trick done there (I'm looking for it). Hardly compatible with french, I fear... – Rmano May 26 '23 at 17:04
  • Would locally forcing the language to Spanish be acceptable ? (I mean, in the item-format) – Rmano May 26 '23 at 17:12
  • If there is no other solution, this is a decent way to do it. I will write to the package maintainer to add something that handles this. – AndréC May 26 '23 at 18:17

1 Answers1

2

When using spanish in babel, the decimal point in math mode numbers is automatically changed to a comma(*). The code doing the magic is in spanish.ldf around line 664, but it's a tad (a very big tad) off the top for me to just leverage it. What you can do is typing the math formulas in Spanish in task items...

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tasks}
\usepackage[spanish, french]{babel}
\newcommand\badtrick[1]{\foreignlanguage{spanish}{\ensuremath{#1}}}
\begin{document}
\begin{tasks}[item-format=\badtrick](1)
\task 0.6\times0.7=0.42
\task 0.05\times0.1=0.005
\task 0.07\times0.08=0.0056
% added to show the problem with automagically change the decimal mark...
\task a.3\times0.006=0.b
\end{tasks}
\end{document}

enter image description here


(*) I am not so much fond of it (because for example $a.0$ is rendered as a,0; I find cleaner to use \num{} from siunitx for that task.)

Rmano
  • 40,848
  • 3
  • 64
  • 125