LaTeX удаляет кратку (диакритический знак краткости) у «й» (и краткая) (Mac OS X)
Ожидает приглашения
Вступление
Данный пост уже не содержит в себе вопрос, т.к. решение проблемы нашлось в процессе написания поста.
Публикую его исключительно с целью добавления решения в выдачи поисковых систем, т.к. поиск решения проблемы по запросам «latex удаляет диакритические знаки», «latex удаляет кратку у й», «latex заменяет й на и» не дал мне ни одного осмысленного поста на эту (или подобные) тему.
Описание проблемы
Кратко
LaTeX съедает дужку у буквы «й». Причём делает это не во всём документе. Буква «й» печатается с краткой (с диакритическим знаком краткости) в титульном листе, помеченном \thispagestyle{empty} и в заголовках subsection. Во всех остальных местах (\section, простой текст, subsubsection, paragraph и т.п.) буква «й» заменяется на «и» (кратка над буквой не печатается). При этом в логах я вижу сообщения вида:
Package inputenc Error: Unicode char \u8:̆ not set up for use with LaTeX.
Подробно
Есть Mac OS X 10.8.2 (Mountain Lion). Есть MacPorts. Из них поставлен пакет texlive (установка производилась 3 дня назад, так что версии свежие):
Список пакетов texlive
[21:01:03] denkoren@denkoren-osx1:~ $ port echo installed | grep texlive
texlive-basic @26926_0+doc
texlive-bin @2012_5+x11
texlive-bin-extra @26926_0+doc
texlive-common @2012_0
texlive-documentation-base @26923_0+doc
texlive-documentation-russian @26661_0+doc
texlive-fonts-recommended @26838_0+doc
texlive-generic-extra @26700_0+doc
texlive-generic-recommended @26785_0+doc
texlive-lang-cyrillic @26689_0+doc
texlive-latex @26725_0+doc
texlive-latex-extra @26807_0+doc
texlive-latex-recommended @26788_0+doc
texlive-pictures @26791_0+doc
texlive-basic @26926_0+doc
texlive-bin @2012_5+x11
texlive-bin-extra @26926_0+doc
texlive-common @2012_0
texlive-documentation-base @26923_0+doc
texlive-documentation-russian @26661_0+doc
texlive-fonts-recommended @26838_0+doc
texlive-generic-extra @26700_0+doc
texlive-generic-recommended @26785_0+doc
texlive-lang-cyrillic @26689_0+doc
texlive-latex @26725_0+doc
texlive-latex-extra @26807_0+doc
texlive-latex-recommended @26788_0+doc
texlive-pictures @26791_0+doc
Есть .tex файл (попытка сверстать диплом):
Заголовки .tex-файла
% Use texdoc.net for help about each TeX package.
\documentclass[a4paper,14pt]{extarticle}
% PDF search & cut'n'paste
\usepackage{cmap}
\renewcommand{\rmdefault}{cmr}
\renewcommand{\sfdefault}{ftx}
\renewcommand{\ttdefault}{cmtt}
% Cyrillic support
\usepackage{mathtext}
\usepackage[T2A]{fontenc}
\DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it}
%? Also be sure to add
%
%? english hyphen
%? ruseng ruenhyph
%? =russian
%
%? to /opt/local/var/db/texmf/tex/generic/config/language.dat
% I'm use LaTeX on system with native UTF-8 encoding. So, tell LaTeX about.
% Windows users should use cp1251 instaed utf8 parameter.
\usepackage[utf8]{inputenc}
\usepackage{textcase}
% I'll use 2 languages in my diploma.
\usepackage[russian,english]{babel}
% AMS font faces
\usepackage{amsmath, amsfonts, amssymb}
% Support for the upright and bold greek letters
\usepackage{bm}
\usepackage[Symbolsmallscale]{upgreek}
\makeatletter
\newcommand{\bfgreek}[1]{\bm{\@nameuse{up#1}}}
\makeatother
% Detect whether PDFLaTeX is in use
\usepackage{ifpdf}
% Graphics
\ifpdf
\usepackage[pdftex]{graphicx}
\else
\usepackage{graphicx}
\fi
%\graphicspath{{images/}}
% Indent the first paragraph as well
\usepackage{indentfirst}
% According to GOST, sections should be called chapters in diploma
\usepackage{titlesec}
\titleformat{\section}[block]{\bfseries\large\sffamily\center}
{\arabic{section}.}{1ex}{}
% Section and subsection numeration format definition.
\titleformat{\subsection}[block]{\bfseries\normalsize\sffamily\raggedright}
{\arabic{section}.\arabic{subsection}.}{1ex}{}
\titleformat{\subsubsection}[block]{\normalsize\sffamily\raggedright}
{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.}{1ex}{}
\titlespacing*{\section} {0pt}{3.50ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{\subsection} {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
%Table of Contents, List of Figures and List of Tables.
\usepackage[titles]{tocloft}
\setcounter{tocdepth}{2} % table of contents depth. Number of levels to print.
% Let's do nice indents at table of contents
\renewcommand{\cftsecnumwidth}{2.5em}
% Let's change subsection indents to look nice:
\renewcommand{\cftsubsecindent}{0.0em}
\renewcommand{\cftsubsecnumwidth}{2.5em}
% 'Section' lines should be filled with dots. (\bfseries to make them bold)
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
% And no 'bold' fonts:
\renewcommand{\cftsecfont}{}
\renewcommand{\cftsecpagefont}{}
\renewcommand{\cftsecaftersnum}{.}
\renewcommand{\cftsubsecaftersnum}{.}
% Provides support for setting the spacing between lines in a document. Package
% options include singlespacing, onehalfspacing, and doublespacing.
% www.ctan.org/tex-archive/macros… /setspace/
\usepackage{setspace}
% Page numbering at the right topmost part of the page
%\pagestyle{myheadings}
% Alternative geometry
\usepackage[top=2cm, bottom=2cm, left=3cm, right=1cm]{geometry}
\ifpdf
\usepackage[pdftex]{hyperref}
\else
\usepackage{hyperref}
\fi
\hypersetup{
unicode=true,
pdftitle={
},
pdfauthor={
Кореневский Денис
},
pdfkeywords={
},
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=blue
}
% Fix links to floats
\usepackage[all]{hypcap}
% Nice citations [1,2,3,4] -> [1-4]
\usepackage[numbers,sort&compress]{natbib}
% [1] -> 1. in the bibliography
\makeatletter
\renewcommand\@biblabel[1]{#1.}
\makeatother
% Russian-styled figure and table captions
\usepackage[labelsep=period]{caption}
% Here we define the relationships for the counters: normaly we should
% reset the eq, figure & table counters every chapter
\makeatletter
\@addtoreset{equation}{section} % Equation counter
\@addtoreset{figure}{section} % Figure counter
\@addtoreset{table}{section} % Table counter
\makeatother
%\renewcommand{\theequation}{\arabic{section}.\arabic{equation}}
%\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}
%\renewcommand{\thetable}{\arabic{section}.\arabic{table}}
% Keeps floats `in their place', preventing them from floating past a
% "\FloatBarrier" command into another section. The floats should not move
% past every "\section".
\usepackage[section]{placeins}
\begin{document}
\section{Секция с буквой Й}
текст секции с буквой Й
\subsection{подсекция с буквой Й}
текст подсекции с буквой Й
\subsubsection{поодподсекция с буквой Й}
текст подподсекции с буквой Й
\end{document}
\documentclass[a4paper,14pt]{extarticle}
% PDF search & cut'n'paste
\usepackage{cmap}
\renewcommand{\rmdefault}{cmr}
\renewcommand{\sfdefault}{ftx}
\renewcommand{\ttdefault}{cmtt}
% Cyrillic support
\usepackage{mathtext}
\usepackage[T2A]{fontenc}
\DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it}
%? Also be sure to add
%
%? english hyphen
%? ruseng ruenhyph
%? =russian
%
%? to /opt/local/var/db/texmf/tex/generic/config/language.dat
% I'm use LaTeX on system with native UTF-8 encoding. So, tell LaTeX about.
% Windows users should use cp1251 instaed utf8 parameter.
\usepackage[utf8]{inputenc}
\usepackage{textcase}
% I'll use 2 languages in my diploma.
\usepackage[russian,english]{babel}
% AMS font faces
\usepackage{amsmath, amsfonts, amssymb}
% Support for the upright and bold greek letters
\usepackage{bm}
\usepackage[Symbolsmallscale]{upgreek}
\makeatletter
\newcommand{\bfgreek}[1]{\bm{\@nameuse{up#1}}}
\makeatother
% Detect whether PDFLaTeX is in use
\usepackage{ifpdf}
% Graphics
\ifpdf
\usepackage[pdftex]{graphicx}
\else
\usepackage{graphicx}
\fi
%\graphicspath{{images/}}
% Indent the first paragraph as well
\usepackage{indentfirst}
% According to GOST, sections should be called chapters in diploma
\usepackage{titlesec}
\titleformat{\section}[block]{\bfseries\large\sffamily\center}
{\arabic{section}.}{1ex}{}
% Section and subsection numeration format definition.
\titleformat{\subsection}[block]{\bfseries\normalsize\sffamily\raggedright}
{\arabic{section}.\arabic{subsection}.}{1ex}{}
\titleformat{\subsubsection}[block]{\normalsize\sffamily\raggedright}
{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.}{1ex}{}
\titlespacing*{\section} {0pt}{3.50ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{\subsection} {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
%Table of Contents, List of Figures and List of Tables.
\usepackage[titles]{tocloft}
\setcounter{tocdepth}{2} % table of contents depth. Number of levels to print.
% Let's do nice indents at table of contents
\renewcommand{\cftsecnumwidth}{2.5em}
% Let's change subsection indents to look nice:
\renewcommand{\cftsubsecindent}{0.0em}
\renewcommand{\cftsubsecnumwidth}{2.5em}
% 'Section' lines should be filled with dots. (\bfseries to make them bold)
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
% And no 'bold' fonts:
\renewcommand{\cftsecfont}{}
\renewcommand{\cftsecpagefont}{}
\renewcommand{\cftsecaftersnum}{.}
\renewcommand{\cftsubsecaftersnum}{.}
% Provides support for setting the spacing between lines in a document. Package
% options include singlespacing, onehalfspacing, and doublespacing.
% www.ctan.org/tex-archive/macros… /setspace/
\usepackage{setspace}
% Page numbering at the right topmost part of the page
%\pagestyle{myheadings}
% Alternative geometry
\usepackage[top=2cm, bottom=2cm, left=3cm, right=1cm]{geometry}
\ifpdf
\usepackage[pdftex]{hyperref}
\else
\usepackage{hyperref}
\fi
\hypersetup{
unicode=true,
pdftitle={
},
pdfauthor={
Кореневский Денис
},
pdfkeywords={
},
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=blue
}
% Fix links to floats
\usepackage[all]{hypcap}
% Nice citations [1,2,3,4] -> [1-4]
\usepackage[numbers,sort&compress]{natbib}
% [1] -> 1. in the bibliography
\makeatletter
\renewcommand\@biblabel[1]{#1.}
\makeatother
% Russian-styled figure and table captions
\usepackage[labelsep=period]{caption}
% Here we define the relationships for the counters: normaly we should
% reset the eq, figure & table counters every chapter
\makeatletter
\@addtoreset{equation}{section} % Equation counter
\@addtoreset{figure}{section} % Figure counter
\@addtoreset{table}{section} % Table counter
\makeatother
%\renewcommand{\theequation}{\arabic{section}.\arabic{equation}}
%\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}
%\renewcommand{\thetable}{\arabic{section}.\arabic{table}}
% Keeps floats `in their place', preventing them from floating past a
% "\FloatBarrier" command into another section. The floats should not move
% past every "\section".
\usepackage[section]{placeins}
\begin{document}
\section{Секция с буквой Й}
текст секции с буквой Й
\subsection{подсекция с буквой Й}
текст подсекции с буквой Й
\subsubsection{поодподсекция с буквой Й}
текст подподсекции с буквой Й
\end{document}
Есть файл с титульной страницей, который инклудится сразу после \begin{document}:
Текст титульной страницы
% $Id: diploma-title.tex 52 2009-06-04 09:46:14Z zyv $
\thispagestyle{empty}
\begin{center}
\begin{footnotesize}
\textsc{Министерство образования и науки Российской Федерации}\\
\textsc{Государственное образовательное учреждение высшего
профессионального образования}\\[0.1cm]
\textsc{«Московский Государственный Технический Университет им.
Н.Э. Баумана» \\
(МГТУ им. Баумана)
}
\textsc{Факультет «Информатика и системы управления»}
\textsc{Кафедра «Компьютерные системы и сети»}
\end{footnotesize}\\[2.0cm]
\end{center}
\begin{flushright}
\begin{minipage}{0.55\textwidth}
\uchyph=0
\center
\MakeTextUppercase{Утверждаю}
\flushleft
Заведующий кафедрой ИУ6,\\[0.1cm]
д.т.н., проф. \underline{\phantom{Четкая подпись}}
Сюзев~В.В.\\[0.2cm]
"\underline{\phantom{day-d}}" \underline{\phantom{месяц прописью}}
20\underline{\phantom{-year}}г.
\end{minipage}
\end{flushright}
\vspace{3.5cm}
\begin{center}
\begin{large}
\MakeTextUppercase{\textbf{тема
}}
\end{large}
\begin{small}
\textsc{Техническое задание на дипломный проект}
\end{small}
\end{center}
\vspace{4.0cm}
\begin{flushright}
\begin{tabular}{ll}
Руководитель, \\
<звания и пр.> &
\begin{tabular}{ll}
\underline{\phantom{Четкая подпись}} &
Овчинников В.А.
\end{tabular}
\\[0.7cm]
Исполнитель, \\
студ. гр. ИУ6-123 &
\begin{tabular}{ll}
\underline{\phantom{Четкая подпись}} &
Кореневский Д.И.
\end{tabular}
\end{tabular}
\end{flushright}
\vfill
\begin{center}
\footnotesize{Москва, 2013г.}
\end{center}
\thispagestyle{empty}
\begin{center}
\begin{footnotesize}
\textsc{Министерство образования и науки Российской Федерации}\\
\textsc{Государственное образовательное учреждение высшего
профессионального образования}\\[0.1cm]
\textsc{«Московский Государственный Технический Университет им.
Н.Э. Баумана» \\
(МГТУ им. Баумана)
}
\textsc{Факультет «Информатика и системы управления»}
\textsc{Кафедра «Компьютерные системы и сети»}
\end{footnotesize}\\[2.0cm]
\end{center}
\begin{flushright}
\begin{minipage}{0.55\textwidth}
\uchyph=0
\center
\MakeTextUppercase{Утверждаю}
\flushleft
Заведующий кафедрой ИУ6,\\[0.1cm]
д.т.н., проф. \underline{\phantom{Четкая подпись}}
Сюзев~В.В.\\[0.2cm]
"\underline{\phantom{day-d}}" \underline{\phantom{месяц прописью}}
20\underline{\phantom{-year}}г.
\end{minipage}
\end{flushright}
\vspace{3.5cm}
\begin{center}
\begin{large}
\MakeTextUppercase{\textbf{тема
}}
\end{large}
\begin{small}
\textsc{Техническое задание на дипломный проект}
\end{small}
\end{center}
\vspace{4.0cm}
\begin{flushright}
\begin{tabular}{ll}
Руководитель, \\
<звания и пр.> &
\begin{tabular}{ll}
\underline{\phantom{Четкая подпись}} &
Овчинников В.А.
\end{tabular}
\\[0.7cm]
Исполнитель, \\
студ. гр. ИУ6-123 &
\begin{tabular}{ll}
\underline{\phantom{Четкая подпись}} &
Кореневский Д.И.
\end{tabular}
\end{tabular}
\end{flushright}
\vfill
\begin{center}
\footnotesize{Москва, 2013г.}
\end{center}
При компиляции из tex в pdf почти у всех символов 'й' убирается кратка (дужка над буквой, диакритический знак, означающий краткость произношения).
Замена происходила, как впоследствии выясилось, только в тексте, «принесённом» из pdf-документа.
Попытки решения проблемы:
Вырезать всю оформительскую часть и оставить только языковые настройки. Попытка скомпилировать в pdf исходный файл с простыми настройками (
Минимальная преамбула документа
) успехом не увенчалась — эффект тот же.\documentclass[a4paper,14pt]{article}
\usepackage{mathtext}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}
\begin{document}
\include{technical-task-title}
\usepackage{mathtext}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}
\begin{document}
\include{technical-task-title}
Найти какие-нибудь сведения в документации к пакету babel, который я использую — безуспешно.
Найти сведения в google и yandex — очень сложно составить поисковый запрос с участием всего одной буквы, попытка уточнить запрос словом «кратка» или «диакритический знак» не даёт нужного эффекта.
Выполнить поиск по сообщению об ошибке из логов — было найдено решение другой проблемы (неразрывный пробел во французском языке). Попытка применить это же решение для кратки не возымела эффекта:
Попытка заменить й с newunicodechar
\usepackage{newunicodechar}
\newunicodechar{:̆}{й}
\newunicodechar{:̆}{й}
Найденное решение
Долго писал это сообщение, попутно пробовал разные действия с текстом. В конце концов обнаружил, что проблема была в коде символа.
Google Docs и шрифты в pdf:
При оформлении документов в docs.google.com (ныне drive.google.com) для текстов исполюзуются какие-то особенные шрифты при экспорте токумента в .pdf формат (возможно Google тут ни при чём и это особенности Mac OS X, но, кажется, в pdf документ «вкомпиливаются» шрифты, используемые в документе, за счёт чего и достигается однообразность отображения на различных платформах/системах).
Это приводит к тому, что в .pdf документе для обозначения буквы «й» используется какой-то особенный код символа (как видно из логов ошибки в начале статьи, отображается как i, у которого вместо точки знак краткости). В дальнейшем я буду обозночать «й» с таким кодом, как «странный» символ (простите за терминологию, ничего более умного я не придумал).
При переводе своего диплома в latex я копировал свои наработки из pdf-ки, полученной из Google Docs. В итоге буква й вставилась в документ (редактировал vim'ом) с этим странным кодом. Оба символа при этом (и со «странным» кодом, и с тем, что вводится при вводе с клавиатуры) отображаются одинаково, внешних различий не заметно.
Замена «странных» символов на нормальные
Не знаю, кто умный, консоль или сам vim, но при копировании этого же символа со «странным» кодом из консоли копируется символ с правильным кодом. Т.е. взять «странный» символ и заменить его на правильный (:%s/й/й/g) не получается.
Решилось копированием «странного» символа из исходного документа и вставкой его в регулярное выражения для замены.
Надеюсь, это будет кому-то полезно
Возможно, это не самое правильное место для публикации решения возникшего вопроса без помощи сообщества, но более подходящих я не нашёл (пост не тянет на самостоятельную статью и разбирает лишь очень частную проблему).