Skip to content

Instantly share code, notes, and snippets.

@biiont
Last active October 22, 2015 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biiont/500d5003db0521fa3c9c to your computer and use it in GitHub Desktop.
Save biiont/500d5003db0521fa3c9c to your computer and use it in GitHub Desktop.
This gist allows to programmatically search and replace in latex taking in consideration word form.
\documentclass{article}
\usepackage{xltxtra}
\usepackage{xecyr}
\usepackage{polyglossia}
\setmainlanguage{russian}
\setotherlanguage{english}
\newfontfamily\cyrillicfont{DejaVu Serif}
\usepackage{xesearch}
\usepackage{xstring}
\newcommand{\korabl}[1]{%
\StrChar{#1}{1}[\headchar]\StrGobbleLeft{#1}{1}[\tailstr]%
\IfStrEq{\headchar}{К}{С}{с}\IfStrEqCase{\tailstr}{%
{орабль}{удно}%
{орабля}{удна}%
{ораблю}{удну}%
{орабли}{удна}%
{ораблём}{удном}%
{ораблем}{удном}%
{ораблями}{удами}%
}[\tailstr]%
}
\SearchList{korabl}{\korabl{#1}}{корабл?}
\begin{document}
\section{Корабль}
Кратенькое описание использования корабля.
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment