2

I write reports in Czech, so naturally, I use the Czech babel package. The problem is that Czech babel makes "-" an active character. I've found that problems arise when I use these libraries

I am using the solutions provided in the StackExchange answer:

\preto\tabular{\shorthandoff{-}}
\preto\siunitx{\shorthandoff{-}}

which makes the "-" character non-active in the used packages. I use a lot of libraries and it's exhausting to find which library is affected.

My question is, whether there is a way to tell to babel library -> do not switch the meaning of the "-" character in a foreign environment. I use utf fonts and for translation lualatex. Perhaps it is possible to use Lua language for this task. But I don't really understand any of it. It would also help me explain what is going on. I tried to figure it out, but my idea is still vague.

MWE:

\documentclass[10pt]{scrbook}
\usepackage[main=czech]{babel}
\usepackage{booktabs}
\usepackage{siunitx}

\usepackage{etoolbox}
\preto\tabular{\shorthandoff{-}}
\preto\siunitx{\shorthandoff{-}}

\usepackage{unicode-math} 
\usepackage{polynom}

\begin{document}
  Number with siunitx \num{1e-9}

 \begin{equation*}
   \polylongdiv[style=C,div=:]{x^4+3x^3-3x^2+3x}{x^2+1}
 \end{equation*}

 \begin{tabular}{ccc}
   A & B & C \\
  \cmidrule{2-3}
  A & B & C \\
  \cline{1-2}
  A & B & C \\
\end{tabular}

\end{document}
2
  • 2
    Sorry, but \preto\siunitx{...} does nothing at all.
    – egreg
    Feb 13, 2021 at 21:43
  • 2
    you can just use \shorthandoff{-} at the top level in the document of you don't want that special meaning of - Feb 13, 2021 at 21:45

1 Answer 1

5

If you do not use the - shorthand just turn it off, there is no need to patch every command separately.

\documentclass[10pt]{scrbook}
\usepackage[main=czech]{babel}
\usepackage{booktabs}
\usepackage{siunitx}



\usepackage{unicode-math} 
\usepackage{polynom}

\begin{document}
\shorthandoff{-}

  Number with siunitx \num{1e-9}
 \begin{equation*}
   \polylongdiv[style=C,div=:]{x^4+3x^3-3x^2+3x}{x^2+1}
 \end{equation*}

 \begin{tabular}{ccc}
   A & B & C \\
  \cmidrule{2-3}
  A & B & C \\
  \cline{1-2}
  A & B & C \\
\end{tabular}

\end{document}
6
  • 2
    In modern (unicode) times probably shorthand=off when loading babel should be the preferred option...
    – Rmano
    Feb 13, 2021 at 22:07
  • 1
    @Rmano possibly (not that I use any shorthands for English anyway:-) But even in 2021 using a UK keyboard it is still a lot easier to type \'e than é (I know that isn't a babel shorthand but still...) Feb 13, 2021 at 22:22
  • @Rmano making - a shorthand at all is unfortunate. Feb 13, 2021 at 22:24
  • 1
    @Rmano on this keyboard actually altgr+e makes é but how do you make a grave or a polish slashed l or ... it's same as math, I can type ∫ but typing \int is a whole lot easier Feb 13, 2021 at 23:01
  • 1
    @DavidCarlisle compose ` e, compose L /... :)
    – hobbs
    Feb 14, 2021 at 6:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .