5

Is there a "sentence stretch" that acts horizontally in a similar way as \setstretch acts vertically?

10

enter image description here

\documentclass{article}
\usepackage{microtype}
\begin{document}

\noindent This is a rather short sentence that will not fill a line.

{\raggedright
\spaceskip  2\fontdimen2 \font
This is a rather short sentence that will not fill a line.

\spaceskip  1em  \relax
This is a rather short sentence that will not fill a line.
}

% Or from microtype:
\noindent\textls[150]{This is a rather short sentence that will not fill a line.}

\end{document}

The above should be used only when needed and with care because inter-word spacing is designed in TeX with good typography in mind for a given font. The deault CM, for example, uses an inter-word spacing of 1/3 em stretchable to 1/2 em and shrinkable to 2/9 em without much uggliness.

Changing \spaceskip will affect inter-word spacing for all fonts by setting an explicit value like 1em or the current font by using a <factor>\fontdimen2 \font.

The second method can use microtype to control spacing between characters. This is acheived via \textls[<percentage>]{<text>}.

If using fontspec with XeLaTeX, for example, you can also use the settings from fontspec like :

\newfontfamily\mycustomfont[LetterSpace=12,WordSpace=2,Ligatures=NoCommon]{<font name>}.

Note:

My solution is especially helpful when designing headers, cover pages, logos, etc. If one is only interested in filling the line, then @egreg's solution is the direct approach.

| improve this answer | |
  • AboAmmar I would like the fontsize to remain the same. – keith77777 Oct 3 '15 at 17:45
  • @keith77777 -- I didn't change the font size, just the spacing between words or characters. – AboAmmar Oct 3 '15 at 17:52
  • Is that not your output below the egreg signature? Sorry, if it's not. – keith77777 Oct 3 '15 at 18:07
  • Yes, the picture above my code is the output. Do you mean some thing? – AboAmmar Oct 3 '15 at 18:12
  • Yes, it's an optical illusion - I was wrong - I beg your pardon. I am accepting your solution but will use egreg's solution as my application is always that of filling a "nearly full" line. Many thanks to you both. – keith77777 Oct 4 '15 at 11:26
13

Sure:

\documentclass{article}
\usepackage{lipsum}

\newenvironment{stretchpars}
 {\par\setlength{\parfillskip}{0pt}}
 {\par}

\begin{document}

\lipsum[2]

\begin{stretchpars}
\lipsum[2]
\end{stretchpars}

\end{document}

enter image description here

| improve this answer | |
3

When working with only a single line of text that you wish to stretch across the text block, there's the stretch option of \makebox:

enter image description here

\documentclass{article}
\setlength{\parindent}{0pt}% Just for this example
\begin{document}

This is a rather short sentence that will not fill a line.

\makebox[\textwidth][s]{This is a rather short sentence that will not fill a line.}

\hrulefill

This is a rather lengthy sentence that will most certainly fill the entire first line of the paragraph.

\makebox[\textwidth][s]{This is a rather lengthy sentence that will most certainly fill the entire first line of the paragraph.}

\end{document}

This will stretch only the spaces to fit the sentence within the given width. Note though that overfull sentences will overrun the text block width. This will not happen when using egreg's \parfillskip approach as you're dealing with paragraphs at that point, rather than single-line sentences.

| improve this answer | |
  • Note for reader: I used \linewidth, because it handles areas of the document with adjusted margins and/or indents (for example, anything that uses the \list environment). \textwidth does not subtract those lengths from its value automatically. – Jonathan Komar Dec 7 '18 at 11:18
0

As for the line to line spacing you can achieve it by

\vspace{length}

or

\vfill

in between sentences.

As for letter-to-letter spacing. LuaTeX with Microtype allows for the desired effect. With:

\textls[150]{VECTOR ANALYSIS}

However on XeTeX you need to use Fontspec and adjust the font features:

LetterSpace = ...

WordSpace = ...

enter image description here

I suggest doing so by creating a command to be able to share these features across different other fonts that you might use, e.g

Say you're sharing certain features for several titling styles, then by creating a command such as:

\newcommand{\titlingFontFeatures}{%

    ...
    LetterSpace = 100,
    WordSpace = 2,
    ...
}

you can then use:

\newcommand{\bigTitle}[1]{{\fontspec
[
    \titlingFontFeatures
]
{Helvetica}
\fontsize{18}{20}\selectfont#1
\par}}

to share features to this new font.

Microtype is just not an option if you're not using pdfLatex, and since you're this serious about fonts you might've migrated to something like XeTeX or LuaTeX a while ago, now, even on LuaTeX, Microtype doesn't have many features that actually work on it. Therefore Fontspec is the way to go.

| improve this answer | |

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.