% \iffalse meta-comment -*- doctex -*-
%
% Copyright (C) 1994 by Mariusz Olko.  All rights reserved.
% Copyright (C) 1997, 1998 by Mariusz Olko and Marcin Woli\'nski.
% Copyright (C) 2000, 2001, 2003, 2007, 2017 by Marcin Woli\'nski.
% All rights reserved.
% 
% This file is part of the package 'Polski'
% ------------------------------------------------------------------
% 
% The file may be distributed under the terms of the LaTeX Project
% Public License, as described in lppl.txt in the base LaTeX
% distribution. Either version 1.2 or, at your option, any later
% version. 
%
% \fi
% \iffalse 
%<*driver>
\documentclass{ltxdoc}
%\errorcontextlines=1000
\usepackage[MeX]{polski}
\usepackage[hidelinks]{hyperref}
%<driver>% Comment next line if you want to print the code
%<driver>%\OnlyDescription
\def\parsedate#1/#2/#3.{\day=#3 \month=#2 \year=#1 }
\parsedate 2017/05/04.
\author{\begin{tabular}[t]{c}
  Mariusz Olko\\[4pt]
  Litter\ae\\
  G\'orczewska 94\Slash96\Slash7\\
  01--117 Warszawa\\
  \textsf{M.Olko@Litterae.com.pl}\\
  \end{tabular}
\hskip20pt
\begin{tabular}[t]{c}
  Marcin Woli\'nski\\[4pt]
  \textsf{wolinski@gust.org.pl}\\
\end{tabular}
}%\\[4pt]

\title{Pakiet \textsc{Polski}\\
      wersja 1.3.4}

\begin{document}
\maketitle
\tableofcontents
\DocInput{polski.dtx}
\end{document}
%
%</driver>
%
% \fi
%
% \CheckSum{1206}
%
% \def\PostScript{\textsc{PostScript}}
% \def\Polski{{\sc Polski}}
% \def\polski{{\sc polski}}
% \def\popolsku{{\sc polski}}
% \def\Babel{\textsc{Babel}}
% 
% \prefixing
% \section{Informacje dla u/zytkownik/ow}
% \subsection{Kr/otki obraz ca/lo/sci}
%
% Paczka dystrybucyjna pakietu \popolsku\ sk/lada si/e z kilku
% zasadniczych cz/e/sci.
% \begin{itemize}
%
% \item Najwa/zniejsz/a cz/e/sci/a jest sam pakiet |polski.sty|,
%   kt/ory dostarcza wszystkich (?) element/ow potrzebnych do sk/ladu
%   w j/ezyku polskim.  Pozwala na stosowanie w~r/o/znych
%   /srodowiskach, z~polskimi wzorcami przenoszenia i~bez, z~polskimi
%   czcionkami i~bez nich.  Posiada te/z mo/zliwo/s/c upodobnienia
%   si/e na poziomie polece/n w 99\% do \LaMeX{}a.  Szczeg/o/lowy opis
%   pakietu znajduje si/e w nast/epnym rozdziale.
%
% \item Drug/a sk/ladow/a stanowi/a pliki opisu czcionek maj/ace
%   standardowo rozszerzenie |.fd|, a generowane przez program
%   \textsf{DocStrip} z pliku |plfonts.fdd|. Znajduj/a si/e w nich
%   informacje na temat font/ow |PL| czyli polskich wersji font/ow
%   Computer Modern (dystrybuowanych z \LaMeX em) oraz czcionek |PC|
%   czyli polskich wersji czcionek Computer Concrete.  Dzi/eki
%   zawartym tam informacjom czcionki te staj/a si/e dost/epne w Nowym
%   Mechani/xmie Wyboru Font/ow (\emph{ang.} New Font Selection
%   Scheme).  Z pliku |plfonts.fdd| mo/zna wygenerowa/c pliki opisu
%   font/ow zar/owno w Starym Uk/ladzie (OT1) jak i w Uk/ladzie
%   Polskim (OT4).  \iffalse Dodatkowo istnieje mo/zliwo/s/c
%   wygenerowania plik/ow |fd|, kt/ore w miejsce czcionek Computer
%   Modern w Starym Uk/ladzie podstawi/a odpowiednie wersje polskie.
%   Podstawienie takie jest ingerencj/a w cz/e/s/c standardowego
%   \LaTeX{}a i mo/ze, w bardzo rzadkich przypadkach, da/c inne wyniki
%   sk/ladu ni/z przy u/zyciu oryginalnych czcionek Computer Modern.
%   \fi
% \item Ostatni element to dwa dodatkowe pakiety, wspomagaj/ace prac/e
%   w~nietypowych warunkach: \textsc{plprefix} i \textsc{ot1patch}.
%   Ich opis mo/zna znale/x/c w~nich samych.
% \end{itemize}
%
% Kod pakietu \polski\ bazuje na rozwi/azaniach zastosowanych w
% formatach \MeX//\LaMeX\ autorstwa Marka Ry/cko i Bogus/lawa
% Jackowskiego.
%
% \subsection{Jak dzia/la pakiet \polski}
%
% Po za/ladowaniu pakietu zmienione zostaj/a wewn/etrzne kody \TeX a
% dla odno/snych liter polskiego alfabetu w Nowym Uk/ladzie (T1).  Te
% zmiany pozwalaj/a na definiowanie makrokomend, kt/ore maj/a w nazwie
% polskie litery, umo/zliwiaj/a prawid/low/a zamian/e liter ma/lych na
% du/ze, a tak/ze pozwalaj/a algorytmowi przenoszenia wyraz/ow
% traktowa/c polskie litery jako litery.  Nast/epnie podj/ete zostaje
% poszukiwanie polskich wzorc/ow przenoszenia i~ich uaktywnienie.
% Je/zeli wzorce przenoszenia nie zostan/a znalezione, pakiet
% \polski{} wypisuje komunikat o~b/l/edzie i~blokuje przenoszenie
% wyraz/ow.
%
% W kolejnym kroku zdefiniowana zostaje notacja /,ciachowa/'.  Notacja
% ta, wprowadzona w \MeX u przez Ry/ck/e i Jackowskiego, pozwala na
% zapisywanie polskich liter w postaci dw/och znak/ow
% \textit{uko/snik} oraz \textit{litera}.  Taki zapis pozwala na
% przesy/lanie tekst/ow poczt/a elektroniczn/a oraz na prac/e w
% miejscach gdzie nie ma wbudowanego w system wsparcia dla j/ezyka
% polskiego (niekt/ore bardzo stare instalacje \texttt{UNIX}owe).
% Pakiet \polski\ uzyskuje wszystkie polskie litery zdefiniowane w
% standardowym \TeX u (tj. \textit{/o, /z} czy \textit{/l}) za pomoc/a
% standardowych makr \TeX a (tzn. np. |\'o|, |\.z| czy te/z |\l|),
% natomiast litery takie jak \textit{/a} czy \textit{/e} za pomoc/a
% standardowego makra \LaTeX owego |\k|.  Ca/la dalsza /l/aczno/s/c
% pomi/edzy komend/a \textit{ciach litera} a wydrukowanym znakiem jest
% zapewniona poprzez definicje uk/lad/ow czcionek.  To w/la/snie w
% tych plikach jest zdefiniowane, /ze np. w Starym Uk/ladzie (OT1)
% liter/e \textit{/o} otrzymuje si/e przez z/lo/zenie akcentu
% \textit{\symbol{19}} oraz litery \textit{o} natomiast w Uk/ladach
% Nowym (T1) oraz Polskim (OT4) przez postawienie znaku o kodzie 161.
% Daje to du/z/a elastyczno/s/c i pozwala na bardzo /latwe u/zycie
% czcionek w dowolnym sensownym uk/ladzie.  Do korzystania z czcionek
% |pl| zdefiniowany zosta/l nowy uk/lad czcionek nazwany |OT4|.
% Szczeg/o/lowe informacje o funkcjonowania uk/lad/ow czcionek mo/zna
% znale/x/c w plikach standardowej dystrybycji \LaTeX a |ltoutenc.dtx|
% oraz |fntguide.tex|.
%
% Pakiet \polski\ pozwala na sk/lad z r/o/znymi zestawami czcionek w
% r/o/znych uk/ladach.  Pocz/atkowy uk/lad czcionek dokumentu mo/ze
% zosta/c wybrany przez dodanie do wywo/lania pakietu odpowiednich
% opcji (patrz~\ref{uzycie}) lub u/zycie standardowego pakietu
% |fontenc|.
% Je/sli jednak nie zmieniono
% pocz/atkowego uk/ladu, pakiet \polski{} pr/obuje odszuka/c w
% systemie plik |ot4cmr.fd|, zawieraj/acy \LaTeX{}owe opisy czcionek
% |pl|.  Je/zeli taki plik zostanie znaleziony, czynione jest
% za/lo/zenie, /ze w systemie zainstalowane s/a r/ownie/z same
% czcionki |pl| i pakiet zmienia pocz/atkowy uk/lad na |OT4|.
% Je/sli plik nie zostanie odszukany, to uk/lad pozostaje bez zmian.
%
% 
% Pakiet \polski{} przedefiniowuje wszystkie napisy, kt/ore mog/a
% pojawi/c si/e wygenerowane automatycznie przez \LaTeX a, takie jak:
% rozdzia/l, spis tre/sci itp.  Zmieniona zostaje te/z definicja makra
% |\today| tak, aby data by/la drukowana po polsku.  Poniewa/z w
% niekt/orych sytuacjach na ko/ncu daty pisze si/e ca/le s/lowo
% ,,roku'', czasami tylko sam/a liter/e ,,r.'', a~czasami nic,
% wprowadzone zosta/lo makro |\PLdateending|, kt/ore rozwija si/e
% zaraz za rokiem i~w~razie potrzeby mo/ze zosta/c /latwo
% przedefiniowane.  Co wi/ecej zachowanie makra |\today| mo/zna
% zmieni/c za pomoc/a nast/epuj/acych opcji pakietu: |roku|, |r.|,
% |noroku| (ta ostatnia jest domy/slna, wi/ec domy/slnie po numerze
% roku nie jest nic dodawane).
%
% Dodatkowo pakiet definiuje makro |\dywiz|, kt/ore pozwala na
% poprawne przeniesienie wyraz/ow z/lo/zonych zapisanych jako
% |bia/lo\dywiz czerwony| i dzielonych jako\\
% \begin{tabular}{@{}r}
% bia/lo-\\-czerwony.
% \end{tabular}
%
% Kolejny problem to pauzy (my/slniki).  Wed/lug polskich zwyczaj/ow
% my/slnik powinien by/c otoczony odst/epami wielko/sci 2pt, oraz nie
% nale/zy rozpoczyna/c wiersza tekstowego my/slnikiem.  Zalecenia te
% realizuje makro |\pauza|.  Makro to zawiera w~sobie potrzebne
% odst/epy, nale/zy wi/ec go u/zywa/c nast/epuj/aco:
% \begin{verbatim}
% By/lo zbyt ciemno\pauza powiedzia/la.
% \end{verbatim}
% Uwaga: definicj/e tego makra traktujemy jako prowizoryczn/a.  Mo/ze
% ulec zmianie!
%
% W polskich zwyczajach typograficznych odst/ep po kropce mi/edzy
% zdaniami powinien by/c taki sam jak pomi/edzy
% wyrazami w /srodku zdania, dlatego pakiet wo/la makro |\frenchspacing|.
%
% Pewne zmiany dotycz/a r/ownie/z matematyki.  Najwa/zniejszymi
% r/o/znicami w~sk/ladzie pomi/edzy matematycznymi wydawnictwami
% polskimi i~angielskoj/ezycznymi jest inny kszta/lt znak/ow
% \textit{mniejsze\dywiz r/owne} i \textit{wi/eksze\dywiz r/owne} oraz
% inne skr/oty stosowane na oznaczenie tangensa, cotangensa i funkcji
% transcendentalnych.  Zmian/a kszta/ltu znak/ow
% \textit{mniejsze\dywiz r/owne} i \textit{wi/eksze\dywiz r/owne} jest
% dokonywana wtedy, je/sli dost/epne s/a matematyczne czcionki |pl|.
% Standardowo pakiet \polski{} definiuje nowe makra |\tg|, |\tgh|,
% |\ctg|, |\ctgh|, |\arc| oraz |\nwd| a nast/epnie\pauza uwaga\pauza
% zmienione zostaj/a symbole drukowane przez standardowe makra \LaTeX
% a |\tan|, |\cot|, |\tanh|, |\coth|, |\arcsin|, |\arccos|, |\arctan|,
% |\gcd|.  Dla pe/lno/sci jest te/z definiowane makro |\arccot|,
% kt/orego z~tajemniczych przyczyn nie ma w~wersji oryginalnej.
% Przedefiniowanie tych makr pozwala na cytowanie tych samych wzor/ow
% w pracy polskiej i~angielskiej bez konieczno/sci zmieniania ich
% zapisu.  Standardowe symbole s/a zmieniane poniewa/z \LaTeX\ (czy
% te/z \TeX) dawno przesta/l by/c tylko systemem sk/ladu.  Sta/l si/e
% obecnie j/ezykiem, w kt/orym zapisywane s/a wzory matematyczne i
% jest bardzo wa/zne jest aby, je/sli jest to mo/zliwe, nie zmienia/c
% ,,standardu'' zapisu tego j/ezyka, lecz co najwy/zej dostosowywa/c
% spos/ob w jaki jest on prezentowany na wydruku.
%
%
% \subsection{Do/l/aczenie pakietu \polski{} do dokumentu}
% \label{uzycie}
%
% Pakiet \polski\ jest /ladowany przez
% umieszczenie w preambule dokumentu zlecenia
% \begin{verbatim}
% \usepackage[opcje]{polski}\end{verbatim}
% U/zycie w wywo/laniu pakietu opcji pozwala na dopasowanie jego
% zachowania do istniej/acego /srodowiska i potrzeb.
% \begin{description}
% \item[OT1] /swiadomie nie chcemy zmienia/c uk/ladu czcionek z
% uk/ladu podstawowego wbudowanego w \LaTeX{}a.
% \item[OT4] prze/l/acza uk/lad czcionek na polski (OT4).  Oznacza
% to, /ze w dokumencie b/ed/a wykorzystane czcionki
% |pl|. 
% \item[T1] zmienia uk/lad czcionek na Nowy Uk/lad Czcionek.  Opcja
% jest wygodna np. w po/l/aczeniu z pakietem czcionek
% \PostScript{}owych w uk/ladzie T1.
% \item[QX] zmienia uk/lad czcionek na QX.  U/zyteczna przy sk/ladzie
% fontami produkcji JNS Team: \TeX\ Gyre Termes, \TeX\ Gyre Heros, itd.
% \item[plmath] prze/l/acza czcionki matematyczne na |pl|, tzn.
%  przedefiniowuje alfabety matematyczne i zestawy symboli.  Dodatkowo
%  zmienia \LaTeX ow/a definicj/e symboli wi/eksze\dywiz r/owne oraz
%  mniejsze\dywiz r/owne.
% \item[nomathsymbols] blokuje spolonizowanie przez pakiet znaczenia
%  standardowych \LaTeX{}owych symboli okre/slaj/acych funkcje
%  trygonometryczne oraz relacje wi/eksze\dywiz r/owne i mniejsze\dywiz
%  r/owne
% \item[prefixinginverb] powoduje, /ze notacja prefiksowa nie jest
% wy/l/aczana w~obr/ebie /srodowiska \texttt{verbatim} i~w~argumencie
% polecenia \cs{verb}. (Domy/slnie aktywna).
% \item[noprefixinginverb] powoduje, /ze notacja prefiksowa jest
% wy/l/aczana w~tych kontekstach.
% \item[MeX] jest to tryb 100\% zgodno/sci z \MeX em.  Ta opcja
%  definiuje wszystkie makra, kt/ore s/a normalnie dost/epne dla
%  u/zytkownika w \MeX u.  Pozwala to na kompilacj/e dokument/ow \MeX
%  owych bez dokonywania /zadnych zmian.
% \end{description}
%
% Je/zeli nie u/zyto /zadnej z opcji wyboru uk/ladu font/ow,
% \texttt{polski.sty} pr/obuje w/l/aczy/c fonty PL, je/zeli s/a one
% zainstalowane.  Dotyczy to zar/owno font/ow tekstowych, jak i
% matematycznych.  W~instalacji zawieraj/acej fonty PL wywo/lanie pakietu
% bez opcji jest r/ownowa/zne wywo/laniu
% \begin{verbatim}
% \usepackage[OT4,plmath]{polski}
% \end{verbatim}
%
% Opcja \texttt{OT1} s/lu/zy do powiedzenia pakietowi, /ze u/zytkownik
% /swiadomie u/zywa uk/ladu nie zawieraj/acego kompletu znak/ow potrzebnych
% do sk/ladu po polsku.
%
% \StopEventually{}
%
% Dalsza cz/e/s/c dokumentu opisuje kod samego pakietu oraz plik/ow
% potrzebnych do instalacji czcionek polskich i wzorc/ow przenoszenia
% w \LaTeX u.  Dokumentacja jest w j/ezyku angielskim.
% \nonprefixing
% \selecthyphenation{english}
% 
% \iffalse=============================================================\fi
% \section{Source code of \texttt{polski.sty}}
% \subsection{Writing banners}
% This package should work only with \LaTeXe, so we make sure the
% appropriate message is displayed when another \TeX\ format is used.
%    \begin{macrocode}
%<*style>
\NeedsTeXFormat{LaTeX2e}[1996/12/01]
%    \end{macrocode}
% Announce the name of the package to the world
%    \begin{macrocode}
\ProvidesPackage{polski}[2017/05/04 v1.3.4 Polish language package]
%    \end{macrocode}
%
% \subsection{Category codes and all that}
% \changes{1.3.4}{2017/05/04}{Catcodes should not be changed for
% Unicode engines. This code caused e.g. guillemots to be letters in
% XeTeX.}  The settings described in this section are not appropriate
% for Unicode aware \TeX\ engines.  Hence a check whether the engine
% interprets the letter aogonek (2 bytes in UTF8) as a single entity:
%    \begin{macrocode}
\begingroup
\def\t#1#2!{\def\s{#2}}\t ą!%
\expandafter\endgroup\ifx\s\empty\else
%    \end{macrocode}
%
% Here we will define the codes for Polish diacritical
% characters.  There are several codes we need to set for each of them.
% The most important one is the category code (|catcode|), which
% identifies the character as a letter to \TeX.  
% Other codes to set are lowercase and
% uppercase equivalents (|lccode| and |uccode|) used to determine the
% proper character when lower and upper casing the string.  These are
% now properly set in the kernel.
%    \begin{macrocode}
\@ifpackageloaded{inputenc}{\typeout{\space\space\space
                      Inputenc package detected. Catcodes not changed.}}{%
\catcode`\^^a1=11 %\lccode`\^^a1=`\^^a1 \uccode`\^^a1=`\^^81  % a ogonek
\catcode`\^^a2=11 %\lccode`\^^a2=`\^^a2 \uccode`\^^a2=`\^^82  % c acute
\catcode`\^^a6=11 %\lccode`\^^a6=`\^^a6 \uccode`\^^a6=`\^^86  % e ogonek
\catcode`\^^aa=11 %\lccode`\^^aa=`\^^aa \uccode`\^^aa=`\^^8a  % l crossed
\catcode`\^^ab=11 %\lccode`\^^ab=`\^^ab \uccode`\^^ab=`\^^8b  % n acute
\catcode`\^^f3=11 %\lccode`\^^f3=`\^^f3 \uccode`\^^f3=`\^^d3  % o acute
\catcode`\^^b1=11 %\lccode`\^^b1=`\^^b1 \uccode`\^^b1=`\^^91  % s acute
\catcode`\^^bb=11 %\lccode`\^^bb=`\^^bb \uccode`\^^bb=`\^^9b  % z dot
\catcode`\^^b9=11 %\lccode`\^^b9=`\^^b9 \uccode`\^^b9=`\^^99  % z acute
%    \end{macrocode}
% Now the same for uppercase letters.
%    \begin{macrocode}
\catcode`\^^81=11 %\lccode`\^^81=`\^^a1 \uccode`\^^81=`\^^81  % A ogonek
\catcode`\^^82=11 %\lccode`\^^82=`\^^a2 \uccode`\^^82=`\^^82  % C accute
\catcode`\^^86=11 %\lccode`\^^86=`\^^a6 \uccode`\^^86=`\^^86  % E ogonek
\catcode`\^^8a=11 %\lccode`\^^8a=`\^^aa \uccode`\^^8a=`\^^8a  % L crossed
\catcode`\^^8b=11 %\lccode`\^^8b=`\^^ab \uccode`\^^8b=`\^^8b  % N accute
\catcode`\^^d3=11 %\lccode`\^^d3=`\^^f3 \uccode`\^^d3=`\^^d3  % O acute
\catcode`\^^91=11 %\lccode`\^^91=`\^^b1 \uccode`\^^91=`\^^91  % S acute
\catcode`\^^9b=11 %\lccode`\^^9b=`\^^bb \uccode`\^^9b=`\^^9b  % Z dot
\catcode`\^^99=11 %\lccode`\^^99=`\^^b9 \uccode`\^^99=`\^^99  % Z acute
}
%    \end{macrocode}
% We finish by setting space factor codes (|sfcode|) for uppercase
% letters.  When French spacing is turned off, \TeX\ treats interword
% spacing after full stop in a special manner.  If the last character before
% the period is lowercase letter then \TeX\ assumes it is the end of the
% sentence, and makes the space wider (and more stretchable).
% However, if the last letter is uppercase, then \TeX\ assumes it is an
% abbreviation and doesn't widen the space. (This is not the whole
% truth.  Consult the \TeX book pages 285--287 for details.)  We set
% |sfcode| for Polish capital letters.
%    \begin{macrocode}
\sfcode`\^^81=999    % A ogonek
\sfcode`\^^82=999    % C acute
\sfcode`\^^86=999    % E ogonek
\sfcode`\^^8a=999    % L crossed
\sfcode`\^^8b=999    % N acute
\sfcode`\^^d3=999    % O acute
\sfcode`\^^91=999    % S acute
\sfcode`\^^9b=999    % Z dot
\sfcode`\^^99=999    % Z acute
%    \end{macrocode}
%  This provides for |\mathit| and friends to work correctly for Polish
%  characters (when used with TCX).
%    \begin{macrocode}
\DeclareMathSymbol{^^a1}{\mathalpha}{letters}{`^^a1}
\DeclareMathSymbol{^^a2}{\mathalpha}{letters}{`^^a2}
\DeclareMathSymbol{^^a6}{\mathalpha}{letters}{`^^a6}
\DeclareMathSymbol{^^aa}{\mathalpha}{letters}{`^^aa}
\DeclareMathSymbol{^^ab}{\mathalpha}{letters}{`^^ab}
\DeclareMathSymbol{^^f3}{\mathalpha}{letters}{`^^f3}
\DeclareMathSymbol{^^b1}{\mathalpha}{letters}{`^^b1}
\DeclareMathSymbol{^^bb}{\mathalpha}{letters}{`^^bb}
\DeclareMathSymbol{^^b9}{\mathalpha}{letters}{`^^b9}
\DeclareMathSymbol{^^81}{\mathalpha}{letters}{`^^81}
\DeclareMathSymbol{^^82}{\mathalpha}{letters}{`^^82}
\DeclareMathSymbol{^^86}{\mathalpha}{letters}{`^^86}
\DeclareMathSymbol{^^8a}{\mathalpha}{letters}{`^^8a}
\DeclareMathSymbol{^^8b}{\mathalpha}{letters}{`^^8b}
\DeclareMathSymbol{^^d3}{\mathalpha}{letters}{`^^d3}
\DeclareMathSymbol{^^91}{\mathalpha}{letters}{`^^91}
\DeclareMathSymbol{^^9b}{\mathalpha}{letters}{`^^9b}
\DeclareMathSymbol{^^99}{\mathalpha}{letters}{`^^99}
\fi
%    \end{macrocode}
%
%
% \subsection{Hyphenation}
%
%  \begin{macro}{\selecthyphenation}
% \changes{v1.01}{1998/04/20}{Macro added}
% \changes{v1.02}{2000/05/16}{New langauage allocated only if undefined.
%    Name changed to be Babel compatible.} 
%    Here we define the hyphenation selecting operator.  If a set of
%    hyphenation patterns for a particular language is unavaiable,
%    hyphenation in that language is turned off.  For that we use
%    following trick:  a new language is allocated with no
%    hyphenation patterns.  Then switching to this language
%    effectively switches hyphenation off (many thanks to Marek
%    Ry\'cko). 
%    \begin{macrocode}
\ifx\l@nohyphenation\@undefined
        \newlanguage\l@nohyphenation
\fi
\def\selecthyphenation#1{%
  \expandafter\ifx\csname l@#1\endcsname\relax
    \PackageError{polski}{No hyphenation patterns for language `#1'}
      {Hyphenation in this language will be disabled.}%
    \selecthyphenation{nohyphenation}%
  \else
    \language\csname l@#1\endcsname
  \fi
  }
%    \end{macrocode}
%  \end{macro}
%
%  \changes{v.1.3.4}{2017/05/01}{luaLaTeX compatibility}
% At some point in time lua\LaTeX\ stopped preloading hyphenation
% patterns in the format file.  In case of lua\LaTeX\ we try to load
% the hyphenation patterns for Polish at runtime.  The first \cs{ifx}
% check for \cs{directlua}, which is characteristic for lua engine.
% An older version of lua\LaTeX\ could have Polish patterns preloaded,
% so we check for \cs{l@polish} being defined.
%    \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname directlua\endcsname\relax
\else
\expandafter\ifx\csname l@polish\endcsname\relax
\newlanguage\l@polish
\language\l@polish
\InputIfFileExists{hyph-pl}{}{%
  \PackageError{polski}{Couldn't load hyphenation patterns for Polish}%
  {Missing file hyph-pl.tex from the hyph-utf8 project.}%
}%
\fi\fi
%    \end{macrocode}
% We try to switch to polish hyphenation patterns looking either for
% patterns name used by |hyphen.cfg| from old versions of \popolsku{}
% bundle or for new Babel-like name.
%    \begin{macrocode}
\ifx\polish\undefined
  \selecthyphenation{polish}
\else
    \language\polish
\fi
\lefthyphenmin=2
\righthyphenmin=2
%    \end{macrocode}
% \subsection{Slash notation}
%
% The slash notation was introduced in the macro package 
% {L\kern-.111em\lower.6ex\hbox{E}\kern-.075emX} by
% Bogus\l{}aw Jackowski and Marek Ry\'cko.  It has been used since then in
% many places and became Polish \TeX{} User's Group GUST ``standard''.
% What follows is the implementation of active slash or Polish slash macro.
%
% \DescribeMacro{\Slash} We start by storing slash character
% (catcode 12 meaning |<other>|) in apropriately named macro.
%    \begin{macrocode}
\def\Slash{/}
%    \end{macrocode}
% \DescribeMacro{\PLSlash} Now we define macro |\PLSlash| which will
% actually be used in input files to access polish letters.  It does
% not need to be robust.  If it is, it breaks kerns
% (pointed out by Marcin Woli\'nski).
% \changes{v1.2.3}{2002/03/05}{// caused errors in TOC if used with
% \cs{prefixing}} 
%    \begin{macrocode}
\def\PLSlash#1{%
%    \end{macrocode}
% The first thing we do is to check whether
% the slash character is followed by an allowed character.  The first test
% is for the second slash (or macro |\PLSlash|), in which case we just
% return \emph{slash} character with category code |<other>|.
%    \begin{macrocode}
  \ifx#1\PLSlash
    \ifx\protect\@typeset@protect\else\protect\string\fi\Slash
  \else
%    \end{macrocode}
% If it was not a slash we test for a letter. We
% assume that there are defined macros which expand to the current
% definitions of Polish letters.  We will give them names
% |\PLSlash@<character>|, so now we look if it is defined.
% If comparison with
% |\relax| is true the macro is not defined.  We issue an error
% message with some help.
%    \begin{macrocode}
    \expandafter \ifx \csname PLSlash@\string#1\endcsname \relax
      \PLSlash@error#1%
    \else
%    \end{macrocode}
% If we got here, we can now expand polish character.  However, we
% do that after completing all |\if|s.
%    \begin{macrocode}
      \expandafter\expandafter\expandafter\PLSlash@letter
      \expandafter\expandafter\expandafter#1%
    \fi
  \fi
}

\def\PLSlash@error#1{\PackageError{polski}{%
Illegal pair of characters /\noexpand#1 occurred}{%
Only a character from the set [acelnosxzACELNOSXZ,'<>/-]
                                        can appear after \Slash.\MessageBreak
Proceed, I will omit both \Slash\ and the character following it.\MessageBreak
You can also correct your mistake NOW, typing I followed by\MessageBreak
whatever should be in the place of the offending pair.}}
%    \end{macrocode}
%
%  \begin{macro}{\PlPrIeC}
%    This macro is needed to protect against removing white space in
%    TOC by Polish characters that have definition ending with a macro
%    call (|\l| and |\L|).  The macro is identical to |\IeC| from
%    inputenc package, but we have to define it here not to depend on
%    inputenc.  The name is different not to cause conflict in case
%    inputenc is loaded after plprefix.
%    \begin{macrocode}
\def\PlPrIeC{%
  \ifx\protect\@typeset@protect
    \expandafter\@firstofone
  \else
    \noexpand\PlPrIeC
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
% \DescribeMacro{\PLSlash@letter} This macro is very simple: it just
% invokes another macro with some wild name.
%    \begin{macrocode}
\def\PLSlash@letter#1{\csname PLSlash@#1\endcsname}
%    \end{macrocode}
%
% Next come the definitions of all Polish diacritics and special symbols. 
% For each ``slashed'' character we define a macro expanding to its
% proper definition.
% Polish characters are defined as normal accented
% letters, and we expect that they will expand according to their
% definitions in the current font encoding. This allows us to use the
% same slash notation with any (decent) font encoding.  For example
% T1 and OT4 encodings will use letters, but OT1 will do what it can%
% ---ie.~insert simple accented characters (with |a| and |e| left
% untouched).  For more information on 
% the work of encoding engine consult \LaTeX\ file
% \texttt{ltoutenc.dtx}.
%
% The following macro is just a helper which will be undefined after use.
%    \begin{macrocode}
\def\PL@accent@def#1#2{%
  \expandafter\def \csname PLSlash@\string #1\endcsname{#2}}
%    \end{macrocode}
% The real definition will take place at the beginning of the document.
% This is small optimization.  We assume that the encoding at this
% stage is what will be default for the rest of the document.  If
% document starts in OT1 encoding we warn user that he can loose some
% information from the printout.
%    \begin{macrocode}
\PL@accent@def{a}{\k a}
\PL@accent@def{c}{\@tabacckludge'c}
\PL@accent@def{e}{\k e}
\PL@accent@def{l}{\PlPrIeC{\l}}
\PL@accent@def{n}{\@tabacckludge'n}
\PL@accent@def{o}{\@tabacckludge'o}
\PL@accent@def{s}{\@tabacckludge's}
\PL@accent@def{x}{\@tabacckludge'z}
\PL@accent@def{z}{\.z}
\PL@accent@def{A}{\k A}
\PL@accent@def{C}{\@tabacckludge'C}
\PL@accent@def{E}{\k E}
\PL@accent@def{L}{\PlPrIeC{\L}}
\PL@accent@def{N}{\@tabacckludge'N}
\PL@accent@def{O}{\@tabacckludge'O}
\PL@accent@def{S}{\@tabacckludge'S}
\PL@accent@def{X}{\@tabacckludge'Z}
\PL@accent@def{Z}{\.Z}
\PL@accent@def{<}{\PlPrIeC{\guillemotleft}}
\PL@accent@def{>}{\PlPrIeC{\guillemotright}}
\PL@accent@def{,}{\PlPrIeC{\quotedblbase}}
\PL@accent@def{'}{\PlPrIeC{\textquotedblright}}
\PL@accent@def{-}{\PlPrIeC{\dywiz}}
%
\let \PL@accent@def \undefined
%    \end{macrocode}
%
% \DescribeMacro{\prefixing}  The last touch is the definition of
% the |\prefixing| macro which activates the slash, but only if
% |plprefix| package was't loaded before.  We manage prefixing flag
% |\pr@fix| for compatibility with \MeX.
%    \begin{macrocode}
\@ifpackageloaded{plprefix}{}{%
    \def\prefixing{\catcode`/=\active
        \bgroup \uccode`\~=`/ \uppercase{\egroup \let~\PLSlash}%
        \let\pr@fix=T}
%    \end{macrocode}
% \DescribeMacro{\nonprefixing} and |\nonprefixing| macro which
% deactivates the slash.
%    \begin{macrocode}
    \def\nonprefixing{\catcode`/=12 \let\pr@fix=F}
}
%    \end{macrocode}
%
% \subsection{Maths in Polish}
% \label{redefining-maths}
%
% The next few macros are provided to typeset maths in Polish.
%
% \DescribeMacro{\arc} In Polish, transcendental functions are written
% with a tiny space after |arc| or |ar|.  Here we define macro |\arc| which
% when followed by eg. |\sin| typesets $\arc\sin$.
%    \begin{macrocode}
\def\arc#1{\mathop{\operator@font
     arc\thinspace\escapechar-1 \string#1}\nolimits}
\def\ar#1{\mathop{\operator@font
     ar\thinspace\escapechar-1 \string#1}\nolimits}
%    \end{macrocode}
%
% \DescribeMacro{\tg}\DescribeMacro{\tgh}
% \DescribeMacro{\ctg}\DescribeMacro{\ctgh}
% We also use different abbreviations for tangent and
% cotangent.
%    \begin{macrocode}
\def\tg{\mathop{\operator@font tg}\nolimits}
\def\ctg{\mathop{\operator@font ctg}\nolimits}
\def\tgh{\mathop{\operator@font tgh}\nolimits}
\def\ctgh{\mathop{\operator@font ctgh}\nolimits}
\def\nwd{\mathop{\operator@font nwd}}
%    \end{macrocode}
%
% Finally we take a drastic step and redefine \LaTeX's definitions
% of mathematical functions.  This will allow us to keep the markup 
% independent of the language in which the document is typeset.  We think
% that this is very important, because \TeX\ is today much more than
% just a typesetting tool, it is also a language which is used to exchange
% mathematical formul\ae.  Redefinition will be suppressed when option
% \texttt{nomathsnames} is used.
%    \begin{macrocode}
\def\PL@redef@funcnames{%
  \let\tan=\tg     \let\cot=\ctg
  \let\tanh=\tgh   \let\coth=\ctgh
  \def\arcsin{\arc\sin}
  \def\arccos{\arc\cos}
  \def\arctan{\arc\tg}
  \def\arccot{\arc\ctg}
  \let\gcd\nwd
  }
%    \end{macrocode}
% These redefinitions should be supplemented by appropriate
% greater-than-or-equal and less-than-or-equal symbols.  They are
% introduced by the |plmath| option or autodetection, when we are sure
% we have those symbols available in our fonts.
%
%
% \subsection{Dashes}
%
% \DescribeMacro{\dywiz}
% When a Polish compound word is split at the hyphen, it should be
% typeset with two hyphens: one at the end of line and the second at
% the beginning of the new line.  We provide macro
% |\dywiz| which gives proper hyphenation of compound words.  Kerns
% before and after |\discretionary| allow both parts of the word to be
% considered for hyphenation.
%    \begin{macrocode}
\def\dywiz{\kern0sp\discretionary{-}{-}{-}\penalty10000\hskip0sp\relax}
%    \end{macrocode}
%
%
%  \begin{macro}{\pauza}
%    Polish typographical rules require to put a fixed space of .2em
%    around dashes and forbid breaking a line before a dash.
%    \begin{macrocode}
\newcommand*\pauza{\unskip\kern.2em\textemdash\hskip.2em\ignorespaces}
\newcommand*\ppauza{\unskip\kern.2em\textendash\hskip.2em\ignorespaces}
%    \end{macrocode}
%  \end{macro}
%
% \subsection{Teaching \LaTeX\ to speak Polish}
%
% In early versions of \LaTeX\ there were problems when one wanted to
% customize predefined texts which were inserted automatically by
% \LaTeX\ (such as \emph{Bibliography} or \emph{Chapter}).  They were all
% hidden deep in the definitions of sectioning or other commands.  Now
% they are all defined as simple macros which can easily be redefined
% in language packages.  We will do that here.
%    \begin{macrocode}
\def\prefacename{Przedmowa}
\def\refname{Literatura}
\def\abstractname{Streszczenie}
\def\bibname{Bibliografia}
\def\chaptername{Rozdzia\PLSlash l} % uppercasing in running head must work
\def\appendixname{Dodatek}
\def\contentsname{Spis tre\'sci}
\def\listfigurename{Spis rysunk\'ow}
\def\listtablename{Spis tabel}
\def\indexname{Skorowidz}
\def\figurename{Rysunek}
\def\tablename{Tabela}
\def\partname{Cz\k e\'s\'c}
\def\enclname{Za\l\k aczniki}
\def\ccname{Do wiadomo\'sci}
\def\headtoname{Do}
\def\pagename{Strona}
\def\seename{zob.}
\def\proofname{Dow\'od}
%    \end{macrocode}
% \DescribeMacro{\today}
% Finally we redefine the macro |\today| to print the current date in Polish.
% In Polish documents in some situations it is more appropriate to use 
% the full word \emph{roku}
% (meaning \emph{year}) at the end of the date and sometimes it is more
% natural to use an abbreviation.  The macro |\PLdateending| which expands
% at the end of the date can be easily redefined to suit particular needs.
%    \begin{macrocode}
\def\today{\number\day~\ifcase\month\or
  stycznia\or lutego\or marca\or kwietnia\or maja\or czerwca\or
  lipca\or sierpnia\or wrze\'snia\or pa\'zdziernika\or
  listopada\or grudnia\fi \space\number\year \PLdateending}
%    \end{macrocode}
%
% \subsection{Macros needed later}
% This macro redefines all standard maths fonts.  Now |pl| maths fonts will be
% used instead of |cm| maths fonts.
%    \begin{macrocode}
\def\PL@setmaths{%
%    \end{macrocode}
% We start by leaving sign that we have fonts avaiable to redefine
% |\ge| and |\le| macros.
%    \begin{macrocode}
    \def\PLm@ths{}
%    \end{macrocode}
% We redefine math alphabets for both math versions.  We don't have to
% redefine |\mathrm|, |\mathnormal| or |\mathcal| alphabets, as they
% bound to |operators|, |letters| and |symbols| fonts by default (see
% |fontdef.dtx|.
%
% We must define OT4 encoding if it is not defined yet.
%    \begin{macrocode}
    \@ifundefined{T@OT4}{%
      \input ot4enc.def
    }{}
    \SetMathAlphabet{\mathbf}{normal}{OT4}{cmr}{bx}{n}
    \SetMathAlphabet{\mathsf}{normal}{OT4}{cmss}{m}{n}
    \SetMathAlphabet{\mathit}{normal}{OT4}{cmr}{m}{it}
    \SetMathAlphabet{\mathtt}{normal}{OT4}{cmtt}{m}{n}
%    \end{macrocode}
% We set math alphabets for bold version.
%    \begin{macrocode}
    \SetMathAlphabet{\mathsf}{bold}{OT4}{cmss}{bx}{n}
    \SetMathAlphabet{\mathit}{bold}{OT4}{cmr}{bx}{it}
%    \end{macrocode}
% We redeclare all standard symbol fonts.  We change the definition of
% |\@font@warning| macro to not to scare the user with warning
% messages on the screen about encoding change.
%    \begin{macrocode}
    \bgroup\let\@font@warning\@font@info
    \SetSymbolFont{operators}   {normal}{OT4}{cmr} {m}{n}
    \SetSymbolFont{letters}     {normal}{OML}{plm} {m}{it}
    \SetSymbolFont{symbols}     {normal}{OMS}{plsy}{m}{n}
    \SetSymbolFont{largesymbols}{normal}{OMX}{plex}{m}{n}
    \SetSymbolFont{operators}   {bold}  {OT4}{cmr} {bx}{n}
    \SetSymbolFont{letters}     {bold}  {OML}{plm} {b}{it}
    \SetSymbolFont{symbols}     {bold}  {OMS}{plsy}{b}{n}
    \egroup
%    \end{macrocode}
% As we have just reloaded the maths fonts, we have some new symbols
% available. 
% We redefine greater-than-or-equal and less-than-or-equal 
% signs to conform to Polish typographical conventions.  This is 
% by analogy with that which was done in section~\ref{redefining-maths}.
% Redefinition will be suppressed when option \emph{nomathsnames} is used.
%    \begin{macrocode} 
    \DeclareMathSymbol{\xleq}{3}{symbols}{172} 
    \DeclareMathSymbol{\xgeq}{3}{symbols}{173}
}
%
\def\PL@redef@relations{
    \let\leq=\xleq
    \let\geq=\xgeq
    \let\le=\leq
    \let\ge=\geq
}
%    \end{macrocode}
%
%
% \subsection{Options}
%
% Package \polski\ provides a number of options which customize
% it to the specific environment or needs.  They switch \LaTeX\ to
% different encodings, provide additional macros,~etc.
%
%
% \subsubsection{Option \texttt{plmath}}
% \label{plmath}
% This option redefines all standard maths fonts.  Now |pl| maths fonts will be
% used instead of |cm| maths fonts.
%    \begin{macrocode}
\DeclareOption{plmath}{%
    \PL@setmaths
}
%    \end{macrocode}
%
%
% \subsubsection{Option \texttt{nomathsymbols}}
% \label{nomathsymbols}
% This option supresses redefinition of standard \LaTeX's macros for
% trigonometric functions and for less-or-equal signs.
%    \begin{macrocode}
\DeclareOption{nomathsymbols}{%
    \def\PLn@m@thsn@mes{}
}
%    \end{macrocode}
%
% \subsubsection{Option \texttt{MeX}}
%
% This mode should prepare everything to be \emph{markup} compatible
% with \LaMeX.  This includes macron redefinition.
%    \begin{macrocode}
% \changes{v1.2.2}{2001/08/31}{Redefinition of macron was too early.  OT4
% may be not known yet.} 
\DeclareOption{MeX}{%
  \AtBeginDocument{%
    \@ifundefined{T@OT1}{}{%
    \DeclareTextCommand{\=}{OT1}{\dywiz}%
    \DeclareTextAccent{\macron}{OT1}{22}}%
    \@ifundefined{T@T1}{}{%
    \DeclareTextCommand{\=}{T1}{\dywiz}%
    \DeclareTextAccent{\macron}{T1}{9}}%
    \@ifundefined{T@OT4}{}{%
    \DeclareTextCommand{\=}{OT4}{\dywiz}%
    \DeclareTextAccent{\macron}{OT4}{22}}%
    \@ifundefined{T@QX}{}{%
    \DeclareTextCommand{\=}{QX}{\dywiz}%
    \DeclareTextAccent{\macron}{QX}{9}}%
    }%
    \let\xle\xleq
    \let\xge\xgeq
    \let\polish\l@polish
    \let\english\l@english
    \def\MeX{M\kern-.111em\lower.6ex\hbox{E}\kern-.075emX}
    \DeclareRobustCommand\LaMeX{%   after latex.dtx
        L\kern-.36em
        {\setbox0\hbox{T}%
         \vbox to\ht0{\hbox{%
                            \csname S@\f@size\endcsname
                            \fontsize\sf@size\z@
                            \math@fontsfalse\selectfont
                            A}
                      \vss}%
        }%
        \kern-.15em
        \MeX\@}%
    }
%    \end{macrocode}
%
%
% \subsubsection{Option {\ttfamily T1}}
% This will select T1 encoding for the document.
%    \begin{macrocode}
\DeclareOption{T1}{%
    \@ifundefined{T@T1}{\input{t1enc.def}}{}
    \def\encodingdefault{T1}\fontencoding{T1}%
    \def\PL@ncodingd@fined{}
}
%    \end{macrocode}
%
% \subsubsection{Option {\ttfamily QX}}
% This will select QX encoding for the document.
%    \begin{macrocode}
\DeclareOption{QX}{%
    \@ifundefined{T@QX}{\input{qxenc.def}}{}
    \def\encodingdefault{QX}\fontencoding{QX}%
    \def\PL@ncodingd@fined{}
}
%    \end{macrocode}
%
% \subsubsection{Option {\tt OT1}}
% This will select OT1 encoding for the document.
%    \begin{macrocode}
\DeclareOption{OT1}{%
    \def\encodingdefault{OT1}\fontencoding{OT1}%
    \def\PL@ncodingd@fined{}
}
%    \end{macrocode}
%
%
% \subsubsection{Option {\tt OT4}}
% This will select OT4 encoding for the document.
%    \begin{macrocode}
\DeclareOption{OT4}{%
    \@ifundefined{T@OT4}{\input{ot4enc.def}}{}%
    \def\encodingdefault{OT4}%
    \fontencoding{OT4}%
    \def\PL@ncodingd@fined{}%
}
%    \end{macrocode}
%
% \subsubsection{Options for prefixing in verbatim}
% These decide if prefixing  is active in verbatim:
%    \begin{macrocode}
\DeclareOption{prefixinginverb}{%
        \def\PL@prefixinginverb{1}%
}
\DeclareOption{noprefixinginverb}{%
        \def\PL@prefixinginverb{0}%
}
%    \end{macrocode}
%
% \subsubsection{Options for date ending in \cs{today}}
% 
%    \begin{macrocode}
\DeclareOption{roku}{%
   \def\PLdateending{\nobreakspace roku}
}
\DeclareOption{r.}{%
   \def\PLdateending{\nobreakspace r.}
}
\DeclareOption{noroku}{%
   \def\PLdateending{}
}
%    \end{macrocode}
%
% \subsection{Taking off \dots}
% This is almost the end.  We process all
% the options in the order of their definition and
% switch to french spacing which is also Polish traditional spacing.
%    \begin{macrocode}
\ExecuteOptions{prefixinginverb,noroku}
\ProcessOptions
\frenchspacing
%    \end{macrocode}
%
% We now try to autodetect whether the pl fonts reside on the system.
% We assume, that if there is \verb|OT4cmr.def| file on the system,
% there are also fonts installed.  The autodetection is suppressed if
% any encoding was switched by package options, or redefined before
% the package was loaded.
%    \begin{macrocode}
\def\tempa{OT1}
\ifx\tempa\f@encoding
    \@ifundefined{PL@ncodingd@fined}{%
        \IfFileExists{ot4cmr.fd}{%
            \typeout{\space\space\space
                Switching to Polish text encoding and Polish maths fonts.}
            \@ifundefined{T@OT4}{%
                \input ot4enc.def
            }{}%
            \def\encodingdefault{OT4}
            \fontencoding{OT4}\selectfont
            \PL@setmaths
        }{%
        \typeout{\space\space\space
          Can't locate Polish fonts.  Will use default encoding.}
        }%
%    \end{macrocode}
%
% We set a checkpoint to warn the user if she enters the document in
% OT1 encoding.
%    \begin{macrocode}
        \def\@PL@OT@check{%
            \bgroup
                \def\tempa{OT1}\ifx\tempa\cf@encoding
                    \@ifpackageloaded{ot1patch}{}{%
                        \PackageError{polski}{%
Zaczynasz skladac dokument uzywajac oryginalnych\MessageBreak
czcionek TeXa.  Czcionki te nie maja kompletu polskich\MessageBreak
znakow.  W zwiazku z tym LaTeX bedzie zglaszal bledy.\MessageBreak
\MessageBreak
Zainstaluj czcionki z dystrybucji MeXa dostepne\MessageBreak
na ftp://ftp.gust.org.pl, sprobuj uzyc czcionek EC\MessageBreak
dodajac opcje T1 do wywolania pakietu polski'ego\MessageBreak
lub w ostatecznosci uzyj pakietu ot1patch.}{}}%
                \fi
            \egroup
            \let\@PL@OT@check=\undefined}%
        \AtBeginDocument{\@PL@OT@check}%
    }{%
    \let\PL@ncodingd@fined=\undefined
    }%
\fi
%    \end{macrocode}
% Now we can redefine \LaTeX names for some maths functions and
% relations if it was not suppressed.
%    \begin{macrocode}
\@ifundefined{PLn@m@thsn@mes}{
  \PL@redef@funcnames
  \@ifundefined{PLm@ths}{}{\PL@redef@relations}
  }{}
%    \end{macrocode}
% If prefixing is not to be active in verb, we have to add slash to
% \cs{dospecials}: 
%    \begin{macrocode}
\if 0\PL@prefixinginverb
  \expandafter\def\expandafter\dospecials\expandafter{\dospecials\do\/}
\fi
%    \end{macrocode}
% Cleaning up and undefining some local macros.
%    \begin{macrocode}
\let\PLn@m@thn@mes=\undefined
\let\PLm@ths=\undefined
\let\PL@setmaths=\undefined
\let\PL@redef@relations=\undefined
\let\PL@redef@funcnames=\undefined
\let\PL@prefixinginverb=\undefined
%</style>
%    \end{macrocode}
%
% \section{Configuring \LaTeX's hyphenation patterns}
%
% This section provides code that configures \LaTeX\ kernel to include
% a~selected set of hyphenation patterns.  Nowadays it is not used
% since all distributions provide a~Babel-enabled \LaTeX\ format.
%
% This code will go to file |hyphen.cfg| which, if found, will be read
% by Ini\TeX\ during format generation instead of the standard \LaTeX\
% hyphenation patterns configuration.
%
% First we have to adjust language allocation counter (|\count19|)
% since kernel (incorrectly) causes |\newlanguage| to start allocation
% from 1.
%    \begin{macrocode}
%<*hyphenation>
\global\count19=-1
%    \end{macrocode}
%    The rest of actions is put into a group, so our auxiliary macros
%    will automatically disappear when they are no longer needed.
%    Allocations done by |\newlanguage| are global and so are
%    |\patterns| and |\hyphenation|.
%    \begin{macrocode}
\begingroup
%    \end{macrocode}
%    Here I define a few auxiliary macros needed to process
%    |language.dat|.  Every time \TeX\ sees a new name he puts it into
%    his name pool and it is never freed.  For that reason I don't
%    want to introduce new names for my auxiliary macros.  So my first
%    idea was to use control sequences of length 1 (which are not put
%    into the pool).  But this approach is risky since ``hyphenation
%    files'' commonly contain small pieces of code to adjust their
%    behaviour to format or \TeX\ version used.  So I've decided to
%    redefine locally a few of standard \LaTeX\ macros.
%    This causes code to be less readable, but I'll try to make these
%    names somehow mnemonic.  (I've chosen macros which contribute
%    directly to the current page, which means for sure they're not
%    used by hyphenation files.)
%
%    |\@stopline| will be used as a sentinel delimiting line end.
%    \begin{macrocode}
\def\@stopline{\@stopline}
%    \end{macrocode}
%    |\line| is main macro processing line read from
%    |language.dat|.  The line is passed to |\line| as argument
%    with a space and |\@stopline| appended.  |\line| checks
%    if the line starts with |=| (synonym definition) and based on
%    that passes the line to |\leftline| or |\rightline|.
%    \begin{macrocode}
\def\line#1#2\@stopline{%
  \ifx=#1%
    \leftline#2\@stopline
  \else
    \rightline#1#2\@stopline
  \fi
  }
%    \end{macrocode}
%    |\leftline| is called for synonym lines (with |=| removed).
%    Such lines should contain only a name for the synonym.  So
%    |\leftline| first checks if there is anything after the name
%    and raises and error.
%    \begin{macrocode}
\def\leftline#1 #2\@stopline{%
  \ifx\@stopline#2\@stopline\else
    \errhelp{The line should contain only an equals sign followed by
            the synonym name.}%
    \errmessage{Extra stuff on a synonym line in language.dat:^^J
            =#1 #2}\fi
%    \end{macrocode}
%    Next check if the language name wasn't already used:
%    \begin{macrocode}
  \expandafter\ifx\csname l@#1\endcsname\relax \else
    \errhelp{This probably means your ``language.dat'' contains many
        lines starting with `#1' or `=#1'.  ^^JThe language `#1' will
        be redefined.  This may not be what you want.}%
    \errmessage{Language `#1' already defined}\fi
%    \end{macrocode}
%    Synonyms make no sense when no real language was defined yet.
%    This is checked next. If |\count19| is $-1$ an error is raised
%    and no definition takes place.
%    \begin{macrocode}
  \ifnum\count19=\m@ne
    \errhelp{You cannot put synonyms before first real
        language definition in language.dat.}
    \errmessage{Cannot define `#1' as a language synonym: no language
        defined yet}%
  \else
%    \end{macrocode}
%    Finally the real definition takes place: |l@<language>| is
%    defined with |\chardef| to be last allocated language number. 
%    \begin{macrocode}
    \global\expandafter\chardef\csname l@#1\endcsname\count19
    \wlog{\string\l@#1=\string\language\number\count19}
  \fi
  }
%    \end{macrocode}
%    |\rightline| processes lines that don't start with |=|.  Such
%    lines instruct ini\TeX\ to read one or more hyphenation files.
%
%    The line is split on first space, |#1| being language name, |#2|
%    list of file names.  Note that there is at least one space in
%    input line since we've put one just before |\@stopline|.
%    \begin{macrocode}
\def\rightline#1 #2\@stopline{%
%    \end{macrocode}
%    First check if the language is already defined. If the language
%    name is new it is allocated.
%    \begin{macrocode}
  \expandafter\ifx\csname l@#1\endcsname\relax
    \expandafter\newlanguage\csname l@#1\endcsname
  \else
    \errhelp{This probably means your ``language.dat'' contains many
        lines starting with `#1' or `=#1'.  ^^JThe patterns will be
        merged with the ones already loaded.  This may not be what you
        want.}% 
    \errmessage{Language `#1' already defined}%
  \fi
%    \end{macrocode}
%    Then the language is set as current to begin loading of
%    hyphenation patterns.
%    \begin{macrocode}
  \language\csname l@#1\endcsname
%    \end{macrocode}
%    The language name is added to the list of defined languages kept
%    in |\displaylines|.
%    \begin{macrocode}
  \edef\displaylines{\displaylines, #1}%
%    \end{macrocode}
%    For every language there should be at least one patterns file
%    specified.  So if |#2| is empty we raise an error.
%    \begin{macrocode}
  \ifx\@stopline#2\@stopline
    \errhelp{Hyphenation will be inhibited in language `#1'.}%
    \errmessage{No pattern files specified for language `#1'}%
%    \end{macrocode}
%    Now |\centerline| processes list of file names delimited with
%    |\@stopline|. 
%    \begin{macrocode}
  \else
  \begingroup
  \message{Loading hyphenation patterns for #1.}
  \centerline#2\@stopline
  \endgroup
  \fi
  }
%    \end{macrocode}
%    Macro |\centerline| calls itself recursively until no file name
%    remains on input line.  For each name it tries to load the file.
%    Absence of file is considered to be a fatal error.
%    \begin{macrocode}
\def\centerline#1 #2\@stopline{%
  \InputIfFileExists{#1}{}{%
    \errhelp{Your language.dat file says I should load a file named
    `#1'.^^J  Check whether this name is correct and the file is
    installed. ^^JThe format will not be generated.}%
    \errmessage{Fatal error: patterns file #1 not found}%
    \endgroup\endgroup\@@end}
  \ifx\@stopline#2\@stopline\else \centerline#2\@stopline\fi
  }
%    \end{macrocode}
% 
%  \begin{macro}{\addvspace}
%    This macro is used to ensure that the line from language.dat ends
%    with exactly one space character.
%    \begin{macrocode}
\def\addvspace #1 \*#2\@stopline{%
  \ifx\@stopline#2\@stopline 
    \expandafter\def\expandafter\*\expandafter{\* }%
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
%    With these auxiliaries we can start actual processing.  First the
%    existence of file \texttt{language.dat} is checked and the file
%    is opened.
%    \begin{macrocode}
\openin1 = language.dat
\ifeof1 
  \errhelp{You should have a file named language.dat on your system.
    This file specifies for what languages hyphenation patterns should
    be loaded and where these are kept.  Without this file the format
    will not be generated.}%
  \errmessage{Fatal error: language.dat not found}%
  \endgroup\@@end
\fi
%    \end{macrocode}
%    |\displaylines| is initialized in such a way that language list
%    won't contain starting comma:
%    \begin{macrocode}
\let\displaylines\@gobble
%    \end{macrocode}
%    Now lines from \texttt{language.dat} are read one by one.
%    |\endlinechar| is set to $-1$ to avoid a space that may get on
%    the end of input line.  But after a line is read |\endlinechar|
%    is reset again since code in patterns files may be fragile to
%    such a condition.
%    \begin{macrocode}
\loop
  \endlinechar\m@ne
  \read1 to \*%
  \endlinechar`\^^M
%    \end{macrocode}
%    Empty lines are skipped and others are passed to |\line|
%    with appended single space and the sentinel.  Line is read to
%    |\*|.  This is safe since this macro is only used locally here,
%    and normal value of |\*| is of no use for hyphenation files.
%    \begin{macrocode}
  \ifx\*\empty
  \else
    \expandafter\addvspace\*\* \*\@stopline
    \expandafter\line\*\@stopline
  \fi
%    \end{macrocode}
%    Processing takes place until end of \texttt{language.dat} is
%    found. 
%    \begin{macrocode}
  \ifeof1\else
\repeat
\closein1
%    \end{macrocode}
%    Now another sanity check is made: any reasonable
%    \texttt{language.dat} should contain at least one language
%    definition.  So we refuse to generate format without any
%    hyphenation patterns.
%    \begin{macrocode}
\ifnum\count19=-1
  \errhelp{Your language.dat does not instruct LaTeX to load any
    hyphenation patterns.  Since format with  no hyphenation patterns
    is hardly usable I refuse to generate it.  Check your language.dat
    and try again.}%
  \errmessage{Fatal error: No languages defined in language.dat}%
  \endgroup\@@end
\fi
%    \end{macrocode}
%    Then code to display list of loaded languages is added to
%    |\everyjob| and the group ends.
%    \begin{macrocode}
\edef\displaylines{\the\everyjob
  \noexpand\wlog{Loaded hyphenation patterns for\displaylines.}}
\global\everyjob\expandafter{\displaylines}
\endgroup
\language0
\lefthyphenmin=2 \righthyphenmin=3
%</hyphenation>
%    \end{macrocode}
%
% \section{Font encoding {\tt OT4}}
%
% (This section is not needed any more.  The definition for OT4 is
% present in the \LaTeX\ base.)
%
% Here we define a new encoding.  Its main purpose is to provide the
% link between standard accents such as |\'|,|\.| or |\k| (ogonek),
% and the corresponding characters in the font.  Jackowski's
% fonts will be called |cm|s and |cc|s in this encoding.
%
%    \begin{macrocode}
%<*encoding>
\ProvidesFile{ot4enc.def}[2017/05/04 v1.3.4 Output encoding for polish fonts]
%    \end{macrocode}
%    Declare the encoding.
%    \begin{macrocode}
\DeclareFontEncoding{OT4}{}{}
%    \end{macrocode}
%    Declare the accents.
%    \begin{macrocode}
\DeclareTextAccent{\"}{OT4}{127}
\DeclareTextAccent{\'}{OT4}{19}
\DeclareTextAccent{\.}{OT4}{95}
\DeclareTextAccent{\=}{OT4}{22}
\DeclareTextAccent{\^}{OT4}{94}
\DeclareTextAccent{\`}{OT4}{18}
\DeclareTextAccent{\~}{OT4}{126}
\DeclareTextAccent{\H}{OT4}{125}
\DeclareTextAccent{\u}{OT4}{21}
\DeclareTextAccent{\v}{OT4}{20}
\DeclareTextAccent{\r}{OT4}{23}
%    \end{macrocode}
%    The ogonek accent is available only under a e A \& E.  But we
%    have to provide some definition for \cs{k}. Some accents have to
%    be built by hand as in OT1:
%    \begin{macrocode}
\DeclareTextCommand{\k}{OT4}[1]{%
    \TextSymbolUnavailable{\k{#1}}#1}
\DeclareTextCommand{\b}{OT4}[1]
   {{\o@lign{\relax#1\crcr\hidewidth\sh@ft{29}%
     \vbox to.2ex{\hbox{\char22}\vss}\hidewidth}}}
\DeclareTextCommand{\c}{OT4}[1]
   {\leavevmode\setbox\z@\hbox{#1}\ifdim\ht\z@=1ex\accent24 #1%
    \else{\ooalign{\unhbox\z@\crcr\hidewidth\char24\hidewidth}}\fi}
\DeclareTextCommand{\d}{OT4}[1]
   {{\o@lign{\relax#1\crcr\hidewidth\sh@ft{10}.\hidewidth}}}
%    \end{macrocode}
%    Declare the text symbols.
%    \begin{macrocode}
\DeclareTextSymbol{\AE}{OT4}{29}
\DeclareTextSymbol{\OE}{OT4}{30}
\DeclareTextSymbol{\O}{OT4}{31}
\DeclareTextSymbol{\L}{OT4}{138}
\DeclareTextSymbol{\ae}{OT4}{26}
\DeclareTextSymbol{\guillemotleft}{OT4}{174}
\DeclareTextSymbol{\guillemotright}{OT4}{175}
\DeclareTextSymbol{\i}{OT4}{16}
\DeclareTextSymbol{\j}{OT4}{17}
\DeclareTextSymbol{\l}{OT4}{170}
\DeclareTextSymbol{\o}{OT4}{28}
\DeclareTextSymbol{\oe}{OT4}{27}
\DeclareTextSymbol{\quotedblbase}{OT4}{255}
\DeclareTextSymbol{\ss}{OT4}{25}
\DeclareTextSymbol{\textemdash}{OT4}{124}
\DeclareTextSymbol{\textendash}{OT4}{123}
\DeclareTextSymbol{\textexclamdown}{OT4}{60}
%\DeclareTextSymbol{\texthyphenchar}{OT4}{`\-}
%\DeclareTextSymbol{\texthyphen}{OT4}{`\-}
\DeclareTextSymbol{\textquestiondown}{OT4}{62}
\DeclareTextSymbol{\textquotedblleft}{OT4}{92}
\DeclareTextSymbol{\textquotedblright}{OT4}{`\"}
\DeclareTextSymbol{\textquoteleft}{OT4}{`\`}
\DeclareTextSymbol{\textquoteright}{OT4}{`\'}
%    \end{macrocode}
%    Some symbols are faked from others:
%    \begin{macrocode}
\DeclareTextCommand{\aa}{OT4}
   {{\accent23a}}
\DeclareTextCommand{\AA}{OT4}
   {\leavevmode\setbox0\hbox{h}\dimen@\ht0\advance\dimen@-1ex%
    \rlap{\raise.67\dimen@\hbox{\char'27}}A}
\DeclareTextCommand{\SS}{OT4}
   {SS}
%    \end{macrocode}
%    In the OT4 encoding, \pounds~and \$ share a slot.
%    \begin{macrocode}
\DeclareTextCommand{\textdollar}{OT4}{\nfss@text{%
   \ifdim \fontdimen\@ne\font >\z@
      \slshape
   \else
      \upshape
   \fi
   \char`\$}}
\DeclareTextCommand{\textsterling}{OT4}{\nfss@text{%
   \ifdim \fontdimen\@ne\font >\z@
      \itshape 
   \else 
      \fontshape{ui}\selectfont 
   \fi 
   \char`\$}}
%    \end{macrocode}
%    Declare the composites.
%    \begin{macrocode}
\DeclareTextComposite{\k}{OT4}{A}{129}
\DeclareTextComposite{\'}{OT4}{C}{130}
\DeclareTextComposite{\k}{OT4}{E}{134}
\DeclareTextComposite{\'}{OT4}{N}{139}
\DeclareTextComposite{\'}{OT4}{S}{145}
\DeclareTextComposite{\'}{OT4}{Z}{153}
\DeclareTextComposite{\.}{OT4}{Z}{155}
\DeclareTextComposite{\k}{OT4}{a}{161}
\DeclareTextComposite{\'}{OT4}{c}{162}
\DeclareTextComposite{\k}{OT4}{e}{166}
\DeclareTextComposite{\'}{OT4}{n}{171}
\DeclareTextComposite{\'}{OT4}{s}{177}
\DeclareTextComposite{\'}{OT4}{z}{185}
\DeclareTextComposite{\.}{OT4}{z}{187}
\DeclareTextComposite{\'}{OT4}{O}{211}
\DeclareTextComposite{\'}{OT4}{o}{243}
%</encoding>
%    \end{macrocode}
%
% \Finale
%
\endinput
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
