1

Using polyglossia package with \setdefaultlanguage{russian} stops producing en-dashes and em-dashes from -- and ---, respectively. Also, no more nice 'upper 99' quotemarks (or any other nice quotemarks) from U+0022.

With \setdefaultlanguage{english} or with default language I get those. With russian I don't. The closest I've come was with babelshorthands=true option, but there are three issues:

  1. the rendering result doesn't look nice (line thickness visibly varies, at least with this font),
  2. spacing with "-- (or "--~ for that matter) and linebreak after "---,
  3. and of course having to use sequences which are mightily inconvenient if writing text in Russian.

I could of course directly input U+2014 and U+2015 and nice quotemarks, but why the package exhibits such strange behaviour at all? No language set (English?) works nice.

I need hyphenation, or I'd just ditch polyglossia, and babel conflicts with something I need.

The MWE:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Liberation Serif}[Ligatures=TeX]
\newfontfamily\cyrillicfont{Liberation Serif}[Script=Cyrillic]
\usepackage{polyglossia}

% these work (german - in its own specific manner): %\setdefaultlanguage{english} %\setdefaultlanguage[babelshorthands=true]{german}

% these don't (strange results with babelshorthands on): \setdefaultlanguage[babelshorthands=true]{russian} %\setdefaultlanguage[babelshorthands=false]{russian} %\setdefaultlanguage{russian}

% polyglossia version: 2023/02/11 v1.60 \begin{document}

..........

-- ~ "en-dash"

--- ~ "em-dash"

"-- ~ "babelshorthands en-dash"

"--- ~ "babelshorthands em-dash"

\end{document}

UPDATE: The suggested reference 'Quotes don't work with polyglossia?', while it offers a solution actually, doesn't qualify as a 'precise' duplicate, I think, because the OP's question there is formulated in such way so that's easy to miss the issue's relation to my question.

cabohah
  • 11,455
yury10578
  • 169
  • 3
    You should set Ligatures=TeX for the Cyrillic font as well. – Marijn Mar 06 '24 at 06:53
  • @Marijn Thank you! So that was all there was to it? That instruction always looked sort of not like a new font, but like a mapping to an existing one. Make an answer from your note, I'll raise it. However, the second part still remains -- dashes as generated by those special " sequences look strangely. – yury10578 Mar 06 '24 at 08:09
  • @yury10578 Never ask more than one question in one question. Always focus to one problem per question. – cabohah Mar 06 '24 at 08:11
  • @cabohah Thank you! It could answer the question, only it looks like it's sort of hard to stumble upon. I didn't see it in search engines or in site's suggestions. – yury10578 Mar 06 '24 at 08:12
  • @cabohah Looked like one-source issue to me. To make a separate issue from it would require researching, though. I haven't used those babel " sequences before, saw them in search engines. – yury10578 Mar 06 '24 at 08:14
  • The thickness part is probably caused by the drawing of the Cyrillic dashes, which have a special length of 0.8em, as two overlapping Latin dashes (see https://github.com/reutenauer/polyglossia/issues/445#issuecomment-698905078), this can lead to incorrect rendering in some pdf viewers at some zoom levels. – Marijn Mar 06 '24 at 08:18
  • Yeah, the sort of famous issue #445 which pops up early in search engines. But wait, how come the default setting in polyglossia work okay? Does it request Ligatures=TeX automatically then? – yury10578 Mar 06 '24 at 08:22
  • @cabohah Having looked at you suggestion again, I think it doesn't quite qualify. The OP there talks about some old tricks with quotes ``'', so the reference's relation to my problem isn't visible too clearly. – yury10578 Mar 06 '24 at 08:26
  • Have you tested the suggested solutions from the answers? The reference relation is the usage and enabling of TeX ligatures, when using \newfontfamily (and indirect also usage of correct starting and ending quotes. BTW: I would suggest to use package csquotes for quotes like shown, e.g., at this question or this answer.) – cabohah Mar 06 '24 at 08:47
  • @cabohah Of course I did, right away. But I'm not a pro in Latex, not by a long shot. It just wasn't obvious to me how the talk about ``quotes'' relates to my simple "quotes" - and dashes, too.

    (And I remember seeing lots of unwieldy TeX tricks in olden times.)

    – yury10578 Mar 06 '24 at 08:52
  • Re “babel conflicts with something I need”, feel free to ask for help. Maybe your conflict can be solved or there is a workaround. – Javier Bezos Mar 06 '24 at 16:10
  • @Javier Bezos Thank you! It's just I've had this issue 2 years ago, switched to polyglossia then, and since then have forgotten about the issue completely. I deal only occasionaly with Latex-based big projects, mostly it's small stuff. I've just looked into my 2 yrs old notes, and there's something about 'babel conflicts with Greek in maths' (??) It must be with {mathspec} and \setmathsfont(Digits,Latin,Greek){Liberation Serif} which I have there? Go figure. Hope it helps a bit. Anyway, that' – yury10578 Mar 06 '24 at 19:09
  • @yury10578 2 years ago babel was version 3.73. Currently we use version 24.3. babel is one of the packages with excellent support and therefore steady improvement. I wouldn't be surprised if a problem from 2 years ago no longer existed. If it does, a question about it and possibly a report would certainly be useful. – cabohah Mar 07 '24 at 07:33
  • @cabohah Afraid the full info is lost, so we won't know what had been going wrong 2 years ago.

    As for today, I just gave babel a quick try, and I'm honestly impressed. Maybe something will crop up yet, but I can't make it misbehave as of now, also with the mathspec sequence from my notes. I'm definitely 'taking it for a spin'.

    Documentation is comprehensive and pleasant-looking. Version tags are quite a nice touch.

    – yury10578 Mar 07 '24 at 11:34
  • @cabohah Well, no luck with babel, after all. I can't use both a language with babelshorthands defined AND plain doublequotes U+0022. The following space gets 'eaten', and I see in other questions discussions that's an unavoidable effect. I use orgmode for my writing, and going to things like ``'' and \textquotedbl (are you kidding me) definitely seems like a cure worse than illness. Thought I'd let you know. – yury10578 Mar 09 '24 at 05:35
  • You've not understand how to make quotes correctly and how shortcuts like " work. To say it once again clearly: " for quotes is wrong! not only TeXnical but also typographical. There is nothing else I can or should say. – cabohah Mar 09 '24 at 09:41

1 Answers1

1

With \newfontfamily you need to enable TeX-Ligatures, if they should be uses, e.g., for -- or --- or also for quotes. Use

\newfontfamily\cyrillicfont{Liberation Serif}[Script=Cyrillic,Ligatures=TeX]

similar to your already used:

\setmainfont{Liberation Serif}[Ligatures=TeX]

(BTW: Usually Ligatures=TeX is already set for the main font and therefore not needed.) See also question “Quotes don't work with polyglossia?

Additionally I would suggest to use package csquotes for the quotation as shown in this answer. Depending on the quotation style you want, you can additionally use option style, e.g.

\usepackage[style=american]{csquotes}

However it seems, that the babel shorthands "--~ and "--- do not work correctly with polyglossia:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Liberation Serif}
%\usepackage[english,main=russian]{babel}
\setmainfont{Liberation Serif}[Ligatures=TeX]
\newfontfamily\cyrillicfont{Liberation Serif}[Script=Cyrillic]
\usepackage{polyglossia}
\setdefaultlanguage[babelshorthands=true]{russian}
\setotherlanguage{english}
\usepackage[style=american]{csquotes}

\defineshorthand{"`}{\openautoquote} \defineshorthand{"'}{\closeautoquote}

\begin{document}

\selectlanguage{english}\useshorthands{"}

-- ``en-dash''

--- ``em-dash''

"--~ ``babelshorthands em-dash no space''

"--- ``babelshorthands em-dash small space''

\selectlanguage{russian}

-- "`тире"'

--- "`рывок"'

"--~ "`вавилонские сокращения, тире, нет места"'

"--- "`вавилонская стенография em-dash маленькое пространство"'

\end{document}

enter image description here

You would need to redefine these shorthands, too, but IMHO it is easier to use babel instead of polyglossia if you want to use babel shorthands:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Liberation Serif}% explicit option [Ligatures=TeX] not needed
\usepackage[english,main=russian]{babel}
\usepackage[style=american]{csquotes}

\defineshorthand{"`}{\openautoquote} \defineshorthand{"'}{\closeautoquote}

\begin{document}

\selectlanguage{english}

-- ``en-dash''

--- ``em-dash''

"--~ ``babelshorthands em-dash no space''

"--- ``babelshorthands em-dash small space''

\selectlanguage{russian} % Note: All translations by translate.google.com

-- "`тире"'

--- "`рывок"'

"--~ "`вавилонские сокращения, тире, нет места"'

"--- "`вавилонская стенография em-dash маленькое пространство"'

\end{document}

enter image description here

Because babel shorthands are language depending, "--~ and "--- are ignored in the English part.

cabohah
  • 11,455
  • In fact, one should not activate [babelshorthands=true] with polyglossia with Russian (or with other languages, too?) if not actually using babel shorthands in the text. What happens is space after closing quote mark gets 'eaten'. – yury10578 Mar 07 '24 at 05:08