0

I am working on a document that uses both the polyglossia and the csquotes package. However polyglossia stops the automatic switch between quotation styles (according to the selected language) from working. If we take the example from this answer and additionally load the polyglossia package, the quotation style remains the same:

\documentclass{article}
\usepackage{csquotes}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguages{french, american, ngerman, spanish}
%\DeclareQuoteStyle{ngerman}%
%  {\quotedblbase}
%  {\textquotedblright}
%  [0.05em]
%  {\textquoteleft}
%  {\textquoteright}

\begin{document}
  \enquote{UK English} 
  \selectlanguage{american} \enquote{US English} 
  \selectlanguage{spanish} \enquote{Spanish} 
  \selectlanguage{french} \enquote{Français} 
  \selectlanguage{ngerman} \enquote{Deutsche}
\end{document}

enter image description here

Note that compared to the original example, I have also already removed the language options from the \documentclass command, since they would interfere with the \setotherlanguages command of the polyglossia package, resulting in an error ("Command \textspanish already defined.").

I also alredy removed the autostyle option of the csquotes package, since for some reason, the package ends up not knowing the appropriate styles ("No style for language ''.", even though according to this answer, it's supposed to do the trick):

enter image description here

A similar problem was reported here, which is why I tried redefining the corresponding quotation styles as suggested in the answer, however it doesn't have any effect.

(EDIT: I also removed the fontenc, inputenc, and babel packages from the original example.)

3
  • Don't load both babel and polyglossia. Either one of them is enough. Jan 22, 2022 at 13:04
  • 1
    why don't you simply use babel? It will work fine with xelatex and your languages. Jan 22, 2022 at 13:17
  • Hi, thanks for your comments. As I've already pointed out in another comment, loading babel is simply a remnant of the original MWE. I didn't know how it relates to polyglossia and that I should only use either one. I've removed it now, but that doesn't have any effect. In the original project, which is mostly legacy code that I shouldn't tamper with, polyglossia is used (and babel isn't loaded as far as I can tell).
    – mapf
    Jan 22, 2022 at 13:24

2 Answers 2

2

you can use the autostyle option of csquotes. But you should set the languages so that \babelname has the correct value:

\documentclass{article}
\usepackage[autostyle]{csquotes}
\usepackage{polyglossia}
\setdefaultlanguage[variant=british]{english}
\setotherlanguages{french,spanish}
\setotherlanguage[spelling=new]{german}

\begin{document}
  \babelname: \enquote{UK English}
  \selectlanguage[variant=american]{english}\babelname:  \enquote{US English}
  \selectlanguage{spanish}\babelname:  \enquote{Spanish}
  \selectlanguage{french}\babelname:  \enquote{Français}
  \selectlanguage{german}\babelname:  \enquote{Deutsche}
\end{document}

enter image description here

2
  • Ah thank you! Why is there a space after "french" though?
    – mapf
    Jan 22, 2022 at 20:32
  • @mapf In French typographic convention there are spaces before (as well as after) some punctuation marks. polyglossia automatically adds spaces before colons if it is set to French to make sure things look correct.
    – moewe
    Jan 23, 2022 at 7:18
0

After a lot of trial and error, I found that the only thing that worked is to use the \setquotestyle command, as suggested in this post:

\documentclass{article}
\usepackage{csquotes}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguages{french, american, ngerman, spanish}

\begin{document}
  \setquotestyle[british]{english} \enquote{UK English} 
  \setquotestyle[american]{english} \enquote{US English} 
  \selectlanguage{spanish} \setquotestyle[spanish]{spanish} \enquote{Spanish}
  \selectlanguage{french} \setquotestyle[guillemets]{french} \enquote{Français}
  \selectlanguage{ngerman} \setquotestyle[quotes]{german} \enquote{Deutsche}
\end{document}

enter image description here

This is a rather ugly solution though, and I'm not sure why it even works or is necessary in the first place.

7
  • if you are using polyglossia you must be using luatex or xetex so never have \usepackage[T1]{fontenc} or \usepackage[utf8]{inputenc} Jan 22, 2022 at 12:48
  • I see, thanks! I didn't know that. I just copied the code from the example. Removing the commands doesn't seem to change anything though.
    – mapf
    Jan 22, 2022 at 12:54
  • the terminal and log both say Package inputenc Warning: inputenc package ignored with utf8 based engines. (inputenc does nothing other than make that warning, loading fontenc can completely break xelatex font handling and line breaking) Jan 22, 2022 at 13:09
  • also are you sure you want to load both babel and polyglossia at the same time? Jan 22, 2022 at 13:10
  • Thanks for pointing that out! But you're asking the wrong question, loading balbel is also simply a remnant from the original MWE. I don't know how it relates to polyglossia, so I didn't know I should have removed it. Removing it doesn't change anything either though. In the project I'm working on babel isn't loaded as far as I can tell (it's legacy code that I didn't write).
    – mapf
    Jan 22, 2022 at 13:21

You must log in to answer this question.

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