3

Sometimes pdfLaTeX decides to break the first too early and I really can't understand why and how to avoid this. Unfortunately, following our standards, I had to disable word division, which seems to make something in LaTeX work incorrect.

figure

Here's the example

\documentclass[14pt, a4paper]{extreport}
\usepackage{cmap} 
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc} 
\usepackage[english, russian]{babel}
\usepackage{pscyr}
\usepackage{amstext, amssymb, amsfonts, amsmath, amsthm, icomma, mathptmx}

\usepackage[left=30mm, right=1cm, vmargin=2cm]{geometry} 
\geometry{head=17pt,headsep=3mm}

\frenchspacing 
\setlength\parindent{5ex}
\usepackage{indentfirst}
\renewcommand{\rmdefault}{ftm}
\usepackage[onehalfspacing]{setspace}
\newenvironment{singlespread}{\linespread{1}}{\linespread{1.3}} 

\usepackage[babel=true]{microtype} 
\hyphenpenalty=10000
\pretolerance=10000
\setlength\emergencystretch{3em}


%-----------------------------------CONTENT------------------------------------%

\begin{document}


\begin{enumerate}
\item \textbf{distCoeffs}~--- коэффициенты дисторсии (D).
\end{enumerate}

% BAD
На данном этапе, задача сводится к определению массива \textbf{imagePoints}. Его необходимо получить непосредственно по изображениям с камеры. Для этого применяются фотографии шахматной доски и функция \textbf{findChessboardCorners}. Функция принимает изображение в качестве параметра \textbf{image} и кортэж $(n_x, n_y)$ в качестве параметра \textbf{patternSize}, а возвращает координаты углов шахматной доски, найденной на изображении. Чтобы убедиться, что шахматная доска найдена, применяется функция \textbf{drawChessboardCorners}. Она наносит на изображение \textbf{image} вспомогательную графику, отображающую места, в которых были найдены углы шахматной доски \textbf{corners} (рисунок \ref{fig:chessboard}).


\end{document}

Please point me at least on how to get rid of it here without making each space unbreakable

  • might be known in russian, but in any case it would help others a great deal if you provided a full manual example that others could just copy and test immediately – daleif May 18 '16 at 7:46
  • it seems to have reproduced easily, I added an example – Himura May 18 '16 at 7:59
  • pscyr isnt in texlive or ctan and if I run your document without \usepackage{pscyr} I get no big spaces – David Carlisle May 18 '16 at 8:02
  • if you really wish, you can use this manual to install it blog.harrix.org/?p=444 there are many screenshots and you can google translate this page – Himura May 18 '16 at 8:03
  • with hyphenation turned off you should almost certainly set \setlength\emergencystretch{3em} (or some such length) to give tex a chance. – David Carlisle May 18 '16 at 8:04
6

pscyr isn't in the main distributions but I can get a similar effect without it if I change some word lengths by appending x in a few places

enter image description here

really

\pretolerance=10000  % Разрешение на подгон

means "I don't care about bad white space" so you get what you ask for.

better to let tex try harder to linebreak by allowing the later passes even though hyphenation is suppressed but then to increase emergencystretch so the white space is more evenly distributed

Changing to

%\pretolerance=10000  % Разрешение на подгон
\emergencystretch=\textwidth

Produces

enter image description here

\documentclass[14pt, a4paper]{extreport}
\usepackage{cmap} % для кодировки шрифтов в pdf
\usepackage[utf8]{inputenc} % кодировка исходников
\usepackage[T2A]{fontenc} 
\usepackage[english, russian]{babel}
%\usepackage{pscyr}
\usepackage{amstext, amssymb, amsfonts, amsmath, amsthm, icomma, mathptmx} % Формулы

%левое - 30 мм (ГОСТ=25), правое - 10 мм, верхнее и нижнее - 20 мм
\usepackage[left=30mm, right=1cm, vmargin=2cm]{geometry} % Поля страницы
\geometry{head=17pt,headsep=3mm}
%\usepackage{showframe}

\frenchspacing % Одинарный пробел в конце предложений
\setlength\parindent{5ex} % абзацный отступ = 5 знаков
\usepackage{indentfirst} % отделять первую строку раздела абзацным отступом
\renewcommand{\rmdefault}{ftm} % Times New Roman
\usepackage[onehalfspacing]{setspace}% Полуторный интервал
\newenvironment{singlespread}{\linespread{1}}{\linespread{1.3}} % одиночный

\usepackage[babel=true]{microtype} % Точный подгон
\hyphenpenalty=10000  % Зарет переносов
%\pretolerance=10000  % Разрешение на подгон
\emergencystretch=\textwidth

%-----------------------------------CONTENT------------------------------------%

\begin{document}


\begin{enumerate}
\item \textbf{distCoeffs}~--- коэффициенты дисторсии (D).
\end{enumerate}

% BAD
На данном этапе, задача сводится к определению массиваxxxxxx \textbf{imagePointsxxxx}. Его необходимо получитьxxxxx непосредственноxxxxxxxxxxxxxx по изображениям с камеры. Для этого применяются фотографии шахматной доски и функция \textbf{findChessboardCorners}. Функция принимает изображение в качестве параметра \textbf{image} и кортэж $(n_x, n_y)$ в качестве параметра \textbf{patternSize}, а возвращает координаты углов шахматной доски, найденной на изображении. Чтобы убедиться, что шахматная доска найдена, применяется функция \textbf{drawChessboardCorners}. Она наносит на изображение \textbf{image} вспомогательную графику, отображающую места, в которых были найдены углы шахматной доски \textbf{corners} (рисунок \ref{fig:chessboard}).


\end{document}
  • Thank you very much, it really helped. There's not much places that advices to use \emergencystretch instead of \pretolerance=10000 Strange that people use \pretolerance=10000 so widely – Himura May 18 '16 at 8:25
2

Setting \pretolerance or \tolerance to 10000 means that it is allowed for TeX to produce lines with arbitrary badness much higher than 10000 if computed by the usual formula of the available stretch in the line (e.g., a line with just two words as in your case).

But TeX will still try to opimize the whole paragraph: so with the above setting it can put all badness into a single line (with a nominal badness of 10000 even though in reality the badness is much higher if computed by the normal formula) and make all others decent.

If you use a value of less than 10000 then all the lines will have real and comparable badnesses andthe result is much more even. However in that case TeX may not find any solution at all and then replies with an "overfull" line.

And this is where \emergencystretch comes in. It avoids the overfull but will keep all lines similarily bad. However, I would set it to a much smaller value than \textwidth.

Disabling word division

Above you said that according to your standards you have to disable word division (and to achieve that you tried setting \pretolerance). While setting that to 10000 make TeX always succeed with a solution that has no hyphenation it is not good because it favors bad solutions.

A much better approach, if that is the general goal, is to ensure that there are no hyphenation patterns used so that TeX simply can't hyphenate in that language (if necessary by defining your own unhyphenated-russian for babel that works like russian but doesn't load patterns.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.