# Hungarian Polyglossia error

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.

• 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 '20 at 21:34
• 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 '20 at 21:38

### Update

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

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
% 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%
{}%
{\xpg@warning{Failed to patch chapter for Hungarian}}%
\fi%
\ifdefined\@part%
\let\xpg@save@part@format\@part%
{}%
{\xpg@warning{Failed to patch part for Hungarian}}%
\fi%
\else%  (not \ifdefined\@memptsize)
% With standard classes
{\@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)
%
\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)
}

\newcommand*{\hungarian@memoir@chaptermark}[1]{%
\markboth{
\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.

• Now I see some cases when my French spacing is somehow ignored. Is it possible that there is a connection to your code? – Kazi bácsi Jan 29 '20 at 22:25
• @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 '20 at 22:26
• French spacing seems to be ineffective if it is switched on in the header. Should it be that way? – Kazi bácsi Jan 30 '20 at 20:41