3

Consider this MWE:

\documentclass[10pt,twoside,openright]{book}

% http://tex.stackexchange.com/a/44701/2595
\usepackage{iftex}
\ifPDFTeX
  \usepackage[greek,danish,english]{babel}
  \usepackage[utf8]{inputenc}
  \usepackage[T1]{fontenc}
  \usepackage{lmodern}
\else
  \usepackage{polyglossia}
  \setdefaultlanguage{english}
  \setotherlanguages{greek,danish} %% (A): causes "Command \proofname already defined."; do it after ntheorem?
  \ifXeTeX
    \usepackage{xltxtra}
  \else
    \usepackage{luatextra}
  \fi
  \defaultfontfeatures{Ligatures=TeX}
\fi

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[framed,amsmath,amsthm,thmmarks]{ntheorem}
% \ifPDFTeX \else %% (B):
%   \setotherlanguages{greek,swedish} % polyglossia leftover; causes "Command \greek already defined."
% \fi

\usepackage{lipsum}

\begin{document}
\lipsum[1]
\end{document}

Compiling this with lualatex --file-line-error test.tex, I get:

...
(/media/texlive/2014/texmf-dist/tex/latex/ntheorem/ntheorem.sty
Style `ntheorem', Version 1.33 <2011/08/15>
(/media/texlive/2014/texmf-dist/tex/latex/base/ifthen.sty)

/media/texlive/2014/texmf-dist/tex/latex/ntheorem/ntheorem.sty:1175: 
LaTeX Error: Command \proofname already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.1175 \ProcessOptions\relax

? 

After seeing "Command \proofname already defined", I tried to look a bit in polyglossia.dtx:

$ awk 'BEGIN{tdo=0;} 
  /captions(danish|swedish|.*greek)/ {print $0; tdo=1;}     
  /proofname/{if(tdo==1){print $0; tdo=0;}}
' `kpsewhich polyglossia.dtx` 

\def\captionsdanish{%
  \def\proofname{Bevis}%
\def\captionsgreek{\monogreekcaptions}%
    \def\captionsgreek{\polygreekcaptions}%
      \def\captionsgreek{\ancientgreekcaptions}%
      \def\captionsgreek{\monogreekcaptions}%
   \def\proofname{Απόδειξη}%
\def\captionsswedish{%
  \def\proofname{Bevis}%

... and indeed, all languages redefine \proofname; so my first idea was to replace (A) with (B) in the MWE - but that results with "Command \greek already defined.".

Now this is the funny thing: this error occurs in (A) only when {greek,danish} is used in \setotherlanguages - it does not occur for, say, {greek,swedish} or just {greek}! (Note that the error in (B) occurs also for Swedish)

Best I could do here, was to compare the polyglossia files for Danish and Swedish, and see if there is a difference - and I tried

meld `kpsewhich gloss-swedish.ldf` `kpsewhich gloss-danish.ldf`

... and I cannot see any significant difference?!

So my question is - how can I use polyglossia with \setotherlanguages{greek,danish} without crashing?

3
  • 1
    Well I would use \usepackage[greek,danish,english]{babel} for xelatex and lualatex too. The main difference between danish and swedish is imho the handling of the dates. Oct 15, 2014 at 10:57
  • Thanks for that @UlrikeFischer - but I thought, polyglossia was replacement for babel? Then again, I just found tex.stackexchange.com/questions/88481/polyglossia-vs-babel, where it mentions: "The relationship between babel and polyglossia with respect to XeTeX is complicated. The general rule of thumb is that if the babel .ldf file uses non-Latin scripts, then you should use polyglossia and generally can't use babel but if it assumes Latin scripts, you may still be able to use babel". So, I guess (haven't tested) here Greek would be a problem?
    – sdaau
    Oct 15, 2014 at 11:10
  • 1
    Your quote is from 2012. Things have changed and babel is moving towards unicode and xelatex/lualatex. If you look in greek.ldf you will see that it contains suitable code for e.g. EU1 and EU2 font encodings. Oct 15, 2014 at 11:57

2 Answers 2

2

If you really want to use polyglossia then reset \proofname to undefined:

[...]
\usepackage{amsmath}
\usepackage{amssymb}
\let\proofname\relax
\usepackage[framed,amsmath,amsthm,thmmarks]{ntheorem}
[...]
3
  • Thanks for that, @Herbert - but would that (in principle) interfere with proof names should the language be switched later on in the document?
    – sdaau
    Oct 15, 2014 at 11:11
  • 1
    sure, it is your decision which version of \proofname you want to use. But it is no problem to use \addtocaptions<language>{\def\proofname{...}}
    – user2478
    Oct 15, 2014 at 11:47
  • Thanks again, @Herbert - I just discovered that this may be due to a syntax error in gloss-danish.ldf (see my answer posting below)... which means, that if I don't want to hack gloss-danish.ldf, indeed the answer is to \relax, as you suggested. Cheers!
    – sdaau
    Oct 15, 2014 at 11:57
1

Ok, I think I got close to why this is happening; I've tried tracing:

...
\usepackage{trace}
...
  \traceon
  \setotherlanguages{greek,danish} %% (A): causes "Command \proofname already defined."; do it after ntheorem?
  \traceoff
...

.. and comparing the outputs for {greek,danish} and {greek,swedish}. For Swedish, the relevant trace is:

{blank space  }
{\par}
{\def}
{changing \captionsswedish=undefined}
{into \captionsswedish=macro:->\def \refname {Referenser}\def \abstractname \ETC
.}
{blank space  }
{\par}
{\def}
{changing \dateswedish=undefined}
{into \dateswedish=macro:->\def \today {\number \day ~\ifcase \ETC.}
{blank space  }
{\par}
{\endinput}
)
{\catcode}

... and for Danish, it is:

{blank space  }
{\par}
{\def}
{changing \captionsdanish=undefined}
{into \captionsdanish=macro:->\def \prefacename {Forord}\def \refname \ETC.}
{\def}
{changing \proofname=undefined}
{into \proofname=macro:->Bevis}
{\def}
{changing \glossaryname=undefined}
{into \glossaryname=macro:->Gloseliste}
{\def}
{changing \today=macro:->\ifcase \month \or January\or Fe\ETC.}
{into \today=macro:->\number \day .~\ifcase \month \or \ETC.}
{blank space  }
{\par}
{\endinput}
)
{\catcode}

Somehow, besides \captionsdanish, this code path also manages to def \proofname, \glossaryname and \today. Why? Let's compare the .ldf files; gloss-swedish.ldf has:

\def\captionsswedish{%
...
  \def\proofname{Bevis}%
  \def\glossaryname{Ordlista}%
  }

\def\dateswedish{%   
  \def\today{%
... }%
    }

... while gloss-danish.ldf has:

\def\captionsdanish{%
...
  \def\alsoname{Se også}}% <--- !!
  \def\proofname{Bevis}%
  \def\glossaryname{Gloseliste}%
  \def\today{\number\day.~\ifcase\month\or
...}

If you see closely, the \def\alsoname closes with two closing braces }}, and the second one thus closes \captionsdanish, and leaves \defs for \proofname, \glossaryname and \today "bare" on the "root level"; and so when this file executes, they execute!

As far as I can see in gloss-english.ldf's \captionsenglish - it is set up the same way \captionsswedish is; so I guess that is a syntax error in \captionsdanish. So, I guess, to really fix the error here, one has to intervene in gloss-danish.ldf. Version-wise, for future reference, I have these versions that showed this problem:

$ grep '\ProvidesPackage' $(kpsewhich polyglossia.sty)
\ProvidesPackage{polyglossia}[2014/05/21 v1.33.5

$ lualatex
This is LuaTeX, Version beta-0.79.1 (TeX Live 2014) (rev 4971) 
7
  • 1
    Yes the two braces are an error, the brace should be behind the \def\today. You should make a bug report. Oct 15, 2014 at 12:02
  • 1
    That's a polyglossia file. Oct 15, 2014 at 12:11
  • 1
    I have submitted the issue with a suggestion for the fix: github.com/reutenauer/polyglossia/issues/85
    – egreg
    Oct 15, 2014 at 12:18
  • 1
    @egreg: You should also mention that one of the braces after \def\alsoname{Se også}}% should move down. Oct 15, 2014 at 12:21
  • 1
    @UlrikeFischer Fixed
    – egreg
    Oct 15, 2014 at 12:23

You must log in to answer this question.

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