5

I want to rerun a few-month-old document with XeLaTeX, and I get an unexpected error messages when loading Hungarian with Polyglossia:

\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{hungarian}
\begin{document}
Példa.
\end{document}

Among numerous others, I get the following error:

You can't use `macro parameter #' in vertical mode.

My MikTeX distribution is updated as of today.

See also on GitHub: https://github.com/reutenauer/polyglossia/issues/388

2
  • 2
    I can replicate the issue you've raised on my system (MacTeX2019, XeTeX 3.14159265-2.6-0.999991, LaTeX2e <2019-10-01> patch level 3, and polyglossia 2019/11/15 v1.46). In can also confirm that the issue appears to be related to the hungarian language choice; it does not arise if english, say, is chosen instead of hungarian.
    – Mico
    Jan 29, 2020 at 21:34
  • 2
    I can replicate it too, on XeTeX, Version 3.14159265-2.6-0.999991 (MiKTeX 2.9.7250 64-bit) and polyglossia v1.46. I will open a github issue.
    – TivV
    Jan 29, 2020 at 21:38

1 Answer 1

6

Update

The issue has been fixed with version 1.47 of polyglossia, released 2020-01-29.

Answer for earlier version

The problem is in the code doing a \renewcommand with a parameter. Recent changes to polyglossia may have created the issue.

Workaround: define separately the command and do \let instead.

\documentclass[a4paper,12pt,twoside]{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{polyglossia}
\setmainlanguage{hungarian}

\makeatletter
\def\hungarian@capsformat{%
  %
  % Change captions
  \if@hungarian@swapcaptions
     % change 'ábra x.x' to 'x.x. ábra'
     \def\fnum@figure{\thefigure.~\figurename}
     %
     % change 'táblázat x.x' to 'x.x. táblázat'
     \def\fnum@table{\thetable.~\tablename}
  \fi
  %
  % change chapter and part headings
  \if@hungarian@swapheadings
     % With titlesec
     \ifdefined\titleformat%
       \ifdefined\@part%
          \let\xpg@save@part@format\@part%
          \patchcmd{\@part}%
                    {\partname\nobreakspace\thepart}%
                    {\thepart.\nobreakspace\partname}%
                    {}%
                    {\xpg@warning{Failed to patch part for Hungarian}}%
       \fi%
       \ifdefined\chapter%
          \titleformat\chapter[display]%
             {\@ifundefined{ttl@fil}{\raggedright}{\ttl@fil}\ttl@fonts\ttl@sizes6}
             {\thechapter.\space\@chapapp}{.8\baselineskip}{\ttl@sizes\z@\ttl@passexplicit}
       \fi%
     \else% (not \ifdefined\titleformat)
       % With KOMA
       \ifdefined\sectionformat%
          \ifdefined\partformat%
            \let\xpg@save@part@format\partformat%
            \renewcommand{\partformat}{\thepart.~\partname}%
          \fi%
          \ifdefined\chapterformat%
            \let\xpg@save@chap@format\chapterformat%
            \renewcommand{\chapterformat}{\mbox{\thechapter\autodot%
                                          \IfUsePrefixLine{\nobreakspace\chapapp}{\enskip}}}%
          \fi%
       \else%  (not \ifdefined\sectionformat)
         % With memoir
         \ifdefined\@memptsize%
           \ifdefined\@makechapterhead%
              \let\xpg@save@chap@format\@makechapterhead%
              \patchcmd{\@makechapterhead}{\printchaptername \chapternamenum \printchapternum}%
                       {\printchapternum.\chapternamenum\printchaptername}%
                       {}%
                       {\xpg@warning{Failed to patch chapter for Hungarian}}%
           \fi%
           \ifdefined\@part%
              \let\xpg@save@part@format\@part%
              \patchcmd{\@part}{\printpartname \partnamenum \printpartnum}%
                               {\printpartnum.\partnamenum\printpartname}%
                               {}%
                               {\xpg@warning{Failed to patch part for Hungarian}}%
           \fi%
         \else%  (not \ifdefined\@memptsize)
           % With standard classes
            \ifdefined\@makechapterhead%
              \let\xpg@save@chap@format\@makechapterhead%
              \patchcmd{\@makechapterhead}%
                       {\@chapapp\space \thechapter}%
                       {\thechapter.\space \@chapapp}%
                       {}%
                       {\xpg@warning{Failed to patch chapter for Hungarian}}%
            \fi%
            \ifdefined\@part%
              \let\xpg@save@part@format\@part%
              \patchcmd{\@part}%
                       {\partname\nobreakspace\thepart}%
                       {\thepart.\nobreakspace\partname}%
                       {}%
                       {\xpg@warning{Failed to patch part for Hungarian}}%
            \fi%  (end \ifdefined\@part)
          \fi% (end \ifdefined\@memptsize)
        \fi% (end \ifdefined\sectionformat)
     \fi% (end \ifdefined\titleformat)
  \fi% (end \if@hungarian@swapheadings)
  %
  % Change running headers
  \if@hungarian@swapheaders
    \ifdefined\chapterformat%
      % With KOMA
      \let\xpg@save@chaptermark@format\chaptermarkformat%
      \renewcommand*\chaptermarkformat{%
         \thechapter\autodot\ \IfChapterUsesPrefixLine{\chapapp\enskip}{}}
    \else% (not \ifdefined\chapterformat)
      \ifdefined\@memptsize%
        % With memoir
        \let\xpg@save@chaptermark@format\chaptermark%
        \let\chaptermark\hungarian@memoir@chaptermark % <----- CHANGED HERE
      \else% (not \ifdefined\@memptsize)
        % With standard classes
        \ifdefined\chaptermark%
           \let\xpg@save@chaptermark@format\chaptermark%
           \patchcmd{\chaptermark}%
                    {\@chapapp\ \thechapter.}%
                    {\thechapter.\ \@chapapp}%
                    {}%
                    {\xpg@warning{Failed to patch chaptermark for Hungarian}}%
        \fi% (end \ifdefined\chaptermark)
      \fi% (end \ifdefined\@memptsize)
    \fi% (end \ifdefined\chapterformat)
  \fi% (end \if@hungarian@swapheaders)
}

\newcommand*{\hungarian@memoir@chaptermark}[1]{%
  \markboth{
    \memUChead{%
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \thechapter.\ \@chapapp\ %
        \fi
      \fi
      #1%
    }%
  }{}%
}
\makeatother

\begin{document}
Példa.
\end{document}

Look for CHANGED HERE and compare with the code in gloss-hungarian.ldf.

3
  • Now I see some cases when my French spacing is somehow ignored. Is it possible that there is a connection to your code? Jan 29, 2020 at 22:25
  • 1
    @Kazibácsi I don't think so: I just replaced \renewcommand{\chaptermark}[1]{...} with \let\chaptermark\hungarian@memoir@chaptermark and didn't touch anything else. I just did a small fix, which however is not relevant to your issue.
    – egreg
    Jan 29, 2020 at 22:26
  • French spacing seems to be ineffective if it is switched on in the header. Should it be that way? Jan 30, 2020 at 20:41

You must log in to answer this question.

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