4

I would like to justify and center text in the following manner:

example

Notice how each line is exactly the same length. How is this done?

I am using a documentclass article and no packages.

7
\begin{center}
\begin{minipage}{.7\linewidth}
jajasdjsdjsd sdj asj
\end{minipage}
\end{center}

or you could use

\begin{quotation}
jajasdjsdjsd sdj asj
\end{quotation}

(which allows page breaking)

or you could use

\begin{abstract}
jajasdjsdjsd sdj asj
\end{abstract}

which is more or less the same, but writes abstract at the start.

1

Notice how each line is exactly the same length.

Surely you want only a narrower paragraph, but as you asked for it, this solution produce the same length also in the last line using to \parfillskip and \emergencystretch. The rest of the obfuscated TeX code is just to be outlandish and not use a simple LaTeX environment (Disclaimer: except for a abstract-like simple paragraph this could produce unexpected problems).

The use of microtype package is optional (if you are tolerant to very bad spacing).

MWE

\documentclass[11pt]{article}
\usepackage{microtype}
%dummy text
\def\blablabla{%
\textbf{Abstract}. nano  is  a small, free and friendly editor 
which aims to replace Pico,  the default editor included in the 
non-free Pine package.  Rather than  just  copying  Pico's  look
and feel, nano also implements some missing (or disabled by 
default) features in Pico, such as ``search and replace''  and 
``go to line and column number''.}

\parskip1em
\begin{document}

\blablabla

{\hsize.5\linewidth\hfill\vbox{\parfillskip0pt%
\emergencystretch.5\linewidth\noindent\blablabla}\hfill}     

\blablabla

\end{document}

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.