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.)

mapf
  • 207
  • Don't load both babel and polyglossia. Either one of them is enough. – Javier Bezos Jan 22 '22 at 13:04
  • 1
    why don't you simply use babel? It will work fine with xelatex and your languages. – Ulrike Fischer Jan 22 '22 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 '22 at 13:24

2 Answers2

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

Ulrike Fischer
  • 327,261
  • Ah thank you! Why is there a space after "french" though? – mapf Jan 22 '22 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 '22 at 07: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.

mapf
  • 207
  • if you are using polyglossia you must be using luatex or xetex so never have \usepackage[T1]{fontenc} or \usepackage[utf8]{inputenc} – David Carlisle Jan 22 '22 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 '22 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) – David Carlisle Jan 22 '22 at 13:09
  • also are you sure you want to load both babel and polyglossia at the same time? – David Carlisle Jan 22 '22 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 '22 at 13:21
  • babel is the standard latex language switch mechanism and polyglossia is an alternative, they are both trying to do the same thing, I doubt that loading them both can have a good outcome. – David Carlisle Jan 22 '22 at 13:37
  • Ah ok, that makes sense. Thanks! I think I've removed all the incompatibilities now though, but the problem remains (thankfully the solution also still works). Since it's legacy code (and a pretty expansive one at that), unfortunately I cannot simply switch to babel, because I don't know what that might entail elsewhere. – mapf Jan 22 '22 at 13:44