Non-breaking space in LaTeX

645 views
Skip to first unread message

smm...@gmail.com

unread,
Apr 3, 2008, 6:29:17 PM4/3/08
to
Is it possible to make some non-breaking spaces not to stretch when
TeX formats the text?
I use LaTeX2e with pdflatex for russian input (using
\usepackage[russian]{babel}). When I format a dialog, almost every
paragraph is started with em dash with nbsp after. And it's very
annoying, when there are some lines, and in every line text starts
from a different position, like this:

--- Some text.
--- Some another text.
--- And one line here.

In input there is:

---~Some text.

---~Some another text.

---~And one line here.

But in some other cases it's better if nbsp still stretches.
I'm a newbie in TeXing, so if there are some good explanations, I'll
be grateful for a link. Thanks.

Enrico Gregorio

unread,
Apr 3, 2008, 7:09:39 PM4/3/08
to
<smm...@gmail.com> wrote:

Say \newcommand{\start}{\mbox{--- }} and

\start Some text

Alternatively, "---\enspace Some text"

Ciao
Enrico

Bob Tennent

unread,
Apr 3, 2008, 7:14:39 PM4/3/08
to
On Thu, 3 Apr 2008 15:29:17 -0700 (PDT), smm...@gmail.com wrote:
> Is it possible to make some non-breaking spaces not to stretch when
> TeX formats the text?
> I use LaTeX2e with pdflatex for russian input (using
> \usepackage[russian]{babel}). When I format a dialog, almost every
> paragraph is started with em dash with nbsp after. And it's very
> annoying, when there are some lines, and in every line text starts
> from a different position, like this:
>
> --- Some text.
> --- Some another text.
> --- And one line here.
>
> In input there is:
>
> ---~Some text.
>
> ---~Some another text.
>
> ---~And one line here.
>
> But in some other cases it's better if nbsp still stretches.
> I'm a newbie in TeXing, so if there are some good explanations, I'll
> be grateful for a link. Thanks.

~ is an interword space, which varies from line to line, depending on
the typesetting.

It seems to me that "non-breaking" isn't the relevant attribute; what
you're looking for is a fixed-width space. So you can replace ~ by \
or \quad or \hspace{...}.

Or, a more LaTeXy way is to use a suitable environment:

\begin{itemize}

\item[---] Some text.

\item[---] Some another text.

\item[---] And one line here.

\end{itemize}


Donald Arseneau

unread,
Apr 3, 2008, 8:40:39 PM4/3/08
to
On Apr 3, 3:29 pm, smm...@gmail.com wrote:
> Is it possible to make some non-breaking spaces not to stretch when
> TeX formats the text?

Yes, but you have to choose separate input commands for
different behavior.

> When I format a dialog, almost every
> paragraph is started with em dash with nbsp after.

An inter-word space isn't the best choice for surrounding a dash
anyway, regardless of its flexibility. Better is a thinspace, which
is smaller, not flexible, non-breaking, and is input using "\,".

> In input there is:
>
> ---~Some text.

Do you know that "---" borduces both an em-dash *and* a
discretionary hyphenation point? Unless you have set

\exhyphenpenalty=10000

you will still get line breaks after your dashes, regardless
that ~ means "non-breaking space". You can make a \dash
command that uses the em-dash character directly, or
uses \mbox{---} to prevent breaks.

\DeclareRobustCommand\dash{\ifhmode\,\fi \mbox{---}\,}

Donald Arseneau as...@triumf.ca

Will Robertson

unread,
Apr 3, 2008, 11:07:30 PM4/3/08
to
On Apr 4, 10:40 am, Donald Arseneau <a...@triumf.ca> wrote:
> An inter-word space isn't the best choice for surrounding a dash
> anyway, regardless of its flexibility.  Better is a thinspace, which
> is smaller, not flexible, non-breaking, and is input using "\,".

I was thinking about this the other day. Don't you think that a thin,
*stetchable* space is better than using \, ? For rather underful
lines, having the dash so tightly bound to the words around it looks a
little tight to me.

Something like this:

\documentclass[twocolumn]{article}
\frenchspacing
\begin{document}
\def\dash{\unskip\,---\,\ignorespaces}
\noindent -lop my morals \dash that is the secret. By and by the North
\bigskip\par
\newskip\halfwordskip
\def\dash{%
\unskip\nobreak
\halfwordskip=0.5\fontdimen2\font
plus 0.5\fontdimen3\font
minus 0.5\fontdimen4\font\relax
\hskip\halfwordskip\nobreak---%
\hskip\halfwordskip\ignorespaces}
\noindent -lop my morals \dash that is the secret. By and by the North
\end{document}

Not that this shows it very well.
What do you think?

Will

Mariano Suárez-Alvarez

unread,
Apr 4, 2008, 12:31:19 AM4/4/08
to

For extra niceness, a trick like the Knuthian \dash---,
gotten with

\def\dash---{...}

so that the actual --- appears in the source is nice ;-)

-- m

Donald Arseneau

unread,
Apr 4, 2008, 5:56:11 AM4/4/08
to
On Apr 3, 7:07 pm, Will Robertson <wsp...@gmail.com> wrote:
> I was thinking about this the other day. Don't you think that a thin,
> *stetchable* space is better than using \, ?

I can see the appeal, especially in cases of extreme difficulty
finding line breaks. However, being "raised" on seeing no
space at all around the long dash, anything more than a thin
space looks strange. Seeing sometimes more is even stranger.

> For rather underful lines, having the dash so tightly bound to
> the words around it looks a little tight to me.

I only reach that stage when the line is so bad letter-spacing
would be an improvement.

Donald Arseneau as...@triumf.ca

Jellby

unread,
Apr 4, 2008, 11:32:11 AM4/4/08
to
Among other things, smm...@gmail.com saw fit to write:

> Is it possible to make some non-breaking spaces not to stretch when
> TeX formats the text?
> I use LaTeX2e with pdflatex for russian input (using
> \usepackage[russian]{babel}). When I format a dialog, almost every
> paragraph is started with em dash with nbsp after. And it's very
> annoying, when there are some lines, and in every line text starts
> from a different position, like this:
>
> --- Some text.
> --- Some another text.
> --- And one line here.
>
> In input there is:
>
> ---~Some text.
>
> ---~Some another text.
>
> ---~And one line here.

I had a similar case when formatting French dialogues, which use em-dash
followed by a space (unlike Spanish dialogues, where there is no space
following the dash). However, in my case I wanted to keep the input as:

---Some text.

---Some other text.

What I did is probably not very robust, but it worked when I need it, and I
have only tried it with the memoir class. I redefined \par to look for the
following characters, like this:

% Dialogue em-dash
\makeatletter
\let\ORIpar=\@@par
\def\dlg{\@ifnextchar-{\dlga}{\@ifnextchar«{\dlgq}{\relax}}}
\def\dlga-{\@ifnextchar-{\dlgb-}{-}}
\def\dlgb--{\@ifnextchar-{\dlgc--}{--}}
\def\dlgc---{\mbox{--- }\ignorespaces}
\def\dlgq«{\@ifnextchar-{\dlgqa«}{«}}
\def\dlgqa«-{\@ifnextchar-{\dlgqb«-}{«-}}
\def\dlgqb«--{\@ifnextchar-{\dlgqc«--}{«--}}
\def\dlgqc«---{\mbox{«--- }\ignorespaces}
\def\@@par{\ORIpar\dlg}
\let\par\@@par
\makeatother

This also considers the cases where the input is:

«---Some text.

---Some other text.»

--
Ignacio __ Fernández Galván
/ /\
Linux user / / \ PGP Pub Key
#289967 / / /\ \ 0x01A95F99
/ / /\ \ \
http://djelibeibi.unex.es
/________\ \ \
jellby \___________\/ yahoo.com

smm...@gmail.com

unread,
Apr 4, 2008, 12:24:06 PM4/4/08
to

> An inter-word space isn't the best choice for surrounding a dash
> anyway, regardless of its flexibility. Better is a thinspace, which
> is smaller, not flexible, non-breaking, and is input using "\,".

I use such spaces in the middle of the lines, but as far as I know, in
russian typography _in dialogues_ normal spaces should be used to
start lines after em dash.

Thanks to everybody who answered in this topic, I see some ways to get
what I want, but as I don't know LaTeX well I'll need some time to
decide, which way to use. Thanks anyway!

sgol...@gmail.com

unread,
Apr 8, 2008, 4:10:42 AM4/8/08
to
On Apr 4, 2:29 am, smm...@gmail.com wrote:
> Is it possible to make some non-breaking spaces not to stretch when
> TeX formats the text?

Babel defines several macros for Russian punctuation. You likely need
"--* for direct speech and "--- for ordinary dash in plain text (in
Russain typography
a dash should be separated from a surrounding text by thing non-
stretching
spaces).

For example:

\documentclass[russian]{article}
\usepackage{babel}
\begin{document}
"--* You KNOW he has not! "--- retorted Polina angrily."--- But where
on
earth did you pick up this Englishman? "--- she said this after a
pause.
\end{document}

Though this source looks a bit ugly to me. So, I've made (locally, in
~/texmf/tex/generic/babel/russian.cfg) - symbol active and defined ---
to setup
correct spaces in the beginning of a paragraph and in the rest of
text. The config
could be found at http://sgolovan.nes.ru/tmp/russian.cfg
It adds option 'activedash' to babel package, which makes the previous
example
source looks the following:

\documentclass[russian,activedash]{article}
\usepackage{babel}
\begin{document}
--- You KNOW he has not! --- retorted Polina angrily.--- But where on
earth did you pick up this Englishman? --- she said this after a
pause.
\end{document}

The obvious drawback is that with this config it becomes impossible to
use - in
numeric constants like \vskip -10pt (one should use \vskip\minus10pt
instead).

Reply all
Reply to author
Forward
0 new messages