reutenauer / polyglossia

An alternative to Babel for XeLaTeX and LuaLaTeX
http://www.ctan.org/pkg/polyglossia
MIT License
190 stars 51 forks source link

Croatian digraph capitalization #552

Closed vedranmiletic closed 1 year ago

vedranmiletic commented 2 years ago

When the template requires the chapter to be printed in all caps in Croatian (e.g. Sphinx template does it), with current digraph configuration it will be printed out as

POGLAVljE,

while it should be

POGLAVLJE.

Note the capital LJ instead of lj. Is there any way to enable digraph to be capitalized?

vedranmiletic commented 2 years ago

CC'ing @ivankokan who I know has been working on this previously.

ivankokan commented 2 years ago

Hi @vedranmiletic, can you please provide some MWE?

vedranmiletic commented 2 years ago

@ivankokan does the following help?

%% Generated by Sphinx.
\def\sphinxdocclass{report}
\documentclass[a4paper,12pt,croatian]{sphinxmanual}
\ifdefined\pdfpxdimen
   \let\sphinxpxdimen\pdfpxdimen\else\newdimen\sphinxpxdimen
\fi \sphinxpxdimen=.75bp\relax
\ifdefined\pdfimageresolution
    \pdfimageresolution= \numexpr \dimexpr1in\relax/\sphinxpxdimen\relax
\fi
%% let collapsible pdf bookmarks panel have high depth per default
\PassOptionsToPackage{bookmarksdepth=5}{hyperref}
%% turn off hyperref patch of \index as sphinx.xdy xindy module takes care of
%% suitable \hyperpage mark-up, working around hyperref-xindy incompatibility
\PassOptionsToPackage{hyperindex=false}{hyperref}
%% memoir class requires extra handling
\makeatletter\@ifclassloaded{memoir}
{\ifdefined\memhyperindexfalse\memhyperindexfalse\fi}{}\makeatother

\PassOptionsToPackage{warn}{textcomp}

\catcode`^^^^00a0\active\protected\def^^^^00a0{\leavevmode\nobreak\ }
\usepackage{cmap}
\usepackage{fontspec}
\defaultfontfeatures[\rmfamily,\sffamily,\ttfamily]{}
\usepackage{amsmath,amssymb,amstext}
\usepackage{polyglossia}
\setmainlanguage{croatian}

\setmainfont{FreeSerif}[
  Extension      = .otf,
  UprightFont    = *,
  ItalicFont     = *Italic,
  BoldFont       = *Bold,
  BoldItalicFont = *BoldItalic
]
\setsansfont{FreeSans}[
  Extension      = .otf,
  UprightFont    = *,
  ItalicFont     = *Oblique,
  BoldFont       = *Bold,
  BoldItalicFont = *BoldOblique,
]
\setmonofont{FreeMono}[
  Extension      = .otf,
  UprightFont    = *,
  ItalicFont     = *Oblique,
  BoldFont       = *Bold,
  BoldItalicFont = *BoldOblique,
]

\usepackage[Sonny]{fncychap}
\ChNameVar{\Large\normalfont\sffamily}
\ChTitleVar{\Large\normalfont\sffamily}
\usepackage{sphinx}

\fvset{fontsize=\small}
\usepackage{geometry}

% Include hyperref last.
\usepackage{hyperref}
% Fix anchor placement for figures with captions.
\usepackage{hypcap}% it must be loaded after hyperref.
% Set up styles of URL: it should be placed after hyperref.
\urlstyle{same}

\addto\captionscroatian{\renewcommand{\contentsname}{Sadržaj}}

\usepackage{sphinxmessages}
\setcounter{tocdepth}{0}

\title{Title}
\date{kol 07, 2022}
\release{Release}
\author{A U Thor}
\newcommand{\sphinxlogo}{\vbox{}}
\renewcommand{\releasename}{Distribucija}
\makeindex
\begin{document}

\chapter{Primjer poglavlja}

\end{document}
jspitz commented 2 years ago

This is not really minimal, and I cannot compile it (due to sphinx class not available here). However, can you try if the following helps?

\makeatletter
\addto\captionscroatian{
  \def\chaptername{Poglav\protect\xpg@hr@digraph{l}{j}e}%
}
\makeatother

At least this solves the following MWE (which does not compile without the fix):

\documentclass{report}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{croatian}

\setmainfont{FreeSerif}

\begin{document}

    \MakeUppercase{\chaptername}

\end{document}
jspitz commented 2 years ago

Let's assume this is fixed. Please report if not.