6

The context is that I'd like to not have to manually choose newlines and rather eyeball the length of text and possibly specify the number of lines or horizontal width the text should take up. I'm interested in various alignment types (left, center, possibly right).

I realize this is a bit of a complex question because I'm not really sure what looks best in terms of different breaks. Take left alignment and the following sentence: The quick brown fox jumps over the lazy dog. Here are a few possibilities:

1:

The quick brown fox
jumps over
the lazy dog.

2:

The quick
brown fox jumps over
the lazy dog.

3:

The quick
brown fox
jumps over the lazy dog.

4:

The quick
brown fox jumps
over the lazy dog.

For left alignment, I personally think a "towers of hanoi" stacking looks best (e.g. #4), but I'm not sure if it makes sense for center alignment.

Other considerations may be punctuation in the text.

An acceptable answer to this question may very well be: this is a bad idea or very difficult. Alternatively, I can see it being something done with an external scripting language (which I haven't really gotten in to yet). I'm really just curious if there is an existing method for this, as it is currently not a necessity for me.

Here is a more precise example dealing with author addresses and titles:

\documentclass[letterpaper]{article}
\usepackage[affil-it]{authblk}

\usepackage[english]{babel}
\usepackage{blindtext}

\title{An efficient method for exploiting midichlorians in weak life-forms}

\author[1,2]{Darth Vader}%

\author[2,3]{Darth Sidious%
  \thanks{Electronic address: \texttt{palpatine@empire.gove}; Corresponding author}}

\affil[1]{Office of the Supreme Commander of the Imperial Foces, The Galactic Empire, The Bridge, Executor}
\affil[2]{Order of the Sith Lords, LiMerge Power Building, The Works, Coruscant}
\affil[3]{Office of the Emperor of the Galaxy, The Galactic Empire, 1000 Imperial Palace, 2 Main St. Coruscant}


\date{\today}

\begin{document}

\maketitle

I ran out of creative energy here ... \blindtext
\end{document}

This results in the following: enter image description here

The title itself is a bit unbalanced, and the second author affiliation has only one word on the second line.

  • 4
    It is pretty unclear to me, what you want to achieve. What is your optimization goal for the line breaking? – Heiko Oberdiek Apr 13 '14 at 23:40
  • 1
    Moreover, TeX is all about automatic line-breaking. The standard for TeX relative to any given context and given any set of hyphenation patterns, penalties etc. just is the line-breaking TeX gives you. That is, TeX does the best it can whatever you give it within whatever parameters you specify. So you seem to want a non-TeX standard but that is off-topic for this site... – cfr Apr 14 '14 at 0:09
  • I didn't have a particular optimization goal (which is also why I didn't think a MWE was necessary for this general and admitedly beginner's question), but cfr's hint is probably pointing me in the right direction - I'll look in to the parameters more, thanks! – bbarker Apr 14 '14 at 2:31
  • 1
    David Carlisle's answer at tex.stackexchange.com/questions/70537/… shows how \nolinebreak penalties can be set between different words of a sentence in order to force LaTeX to make certain breaks less preferable. An example: The\nolinebreak[1] quick brown\nolinebreak[2] fox jumps over the lazy\nolinebreak[1] dog. would penalize line breaking at various points, after the leading "The", between "brown" and "fox", and between "lazy" and "dog". – Steven B. Segletes Apr 14 '14 at 13:11
6

Your question isn't very clear and lacks an example document, but this shows four different setting of teh text, standard justified, sloppy, ragged right and RaggedRight from the ragged2e package. As the text is so short it doesn't really show the differences well so I repeat the settings with a longer paragraph with the text repeated. It still doesn't really show the differences a major difference is the amount of hyphenation that is allowed, but these are short non-hyphenatable words.

Unless you are setting poetry where choice of linebreaking is part of the composition of the works and you want manual control over that, it should be rather rare to manually linebreak text at all when using TeX. So the initial line of your question seems strange with no additional context explaining why manual linebreaking is needed.

enter image description here

\documentclass{article}

\newcommand\qbf{The quick brown fox jumps over the lazy dog. }
\newcommand\qbff{\qbf\qbf\qbf\qbf}
\usepackage{ragged2e}

\begin{document}

\begin{minipage}[t]{3cm}\qbf\end{minipage}
\quad
\begin{minipage}[t]{3cm}\sloppy\qbf\end{minipage}

\bigskip
\begin{minipage}[t]{3cm}\raggedright\qbf\end{minipage}
\quad
\begin{minipage}[t]{3cm}\RaggedRight\qbf\end{minipage}

\bigskip\hrule\bigskip

\begin{minipage}[t]{3cm}\qbff\end{minipage}
\quad
\begin{minipage}[t]{3cm}\sloppy\qbff\end{minipage}

\bigskip
\begin{minipage}[t]{3cm}\raggedright\qbff\end{minipage}
\quad
\begin{minipage}[t]{3cm}\RaggedRight\qbff\end{minipage}

\end{document}



\documentclass{article}

\newcommand\qbf{The quick brown fox jumps over the lazy dog. }
\newcommand\qbff{\qbf\qbf\qbf\qbf}
\usepackage{ragged2e}

\begin{document}

\begin{minipage}[t]{3cm}\qbf\end{minipage}
\quad
\begin{minipage}[t]{3cm}\sloppy\qbf\end{minipage}

\bigskip
\begin{minipage}[t]{3cm}\raggedright\qbf\end{minipage}
\quad
\begin{minipage}[t]{3cm}\RaggedRight\qbf\end{minipage}

\bigskip\hrule\bigskip

\begin{minipage}[t]{3cm}\qbff\end{minipage}
\quad
\begin{minipage}[t]{3cm}\sloppy\qbff\end{minipage}

\bigskip
\begin{minipage}[t]{3cm}\raggedright\qbff\end{minipage}
\quad
\begin{minipage}[t]{3cm}\RaggedRight\qbff\end{minipage}

\end{document}

With the now supplied MWE, you can get various effects depending on how you set the paragraph parameters. The (very old:-) package you are using doesn't give an interface to that but basically it just redefines tabular used by the article package \maketitle to be center, so by redefining center you can cause various texts to move around, for example:

enter image description here

\documentclass[letterpaper]{article}
\usepackage[affil-it]{authblk}
\usepackage{ragged2e}
\makeatletter
\def\maketitle
  {{\@flushglue=.25\textwidth minus.25\textwidth\z@skip
    \hyphenpenalty\@M
    \let\old@date\@date
    \def\@date{\mbox{}\hskip\@flushglue\old@date\hskip\@flushglue\mbox{}\par}%hmm
    \renewenvironment{tabular}[2][]{\par}
                                   {\par}%
  \AB@maketitle}}

\makeatother
\usepackage[english]{babel}
\usepackage{blindtext}

\title{An efficient method for exploiting midichlorians in weak life-forms}

\author[1,2]{Darth Vader}%

\author[2,3]{Darth Sidious%
  \thanks{Electronic address: \texttt{palpatine@empire.gove}; Corresponding author}}

\affil[1]{Office of the Supreme Commander of the Imperial Foces, The Galactic Empire, The Bridge, Executor}
\affil[2]{Order of the Sith Lords, LiMerge Power Building, The Works, Coruscant}
\affil[3]{Office of the Emperor of the Galaxy, The Galactic Empire, 1000 Imperial Palace, 2 Main St. Coruscant}


\date{\today}

\begin{document}


\maketitle

\noindent X\dotfill X

I ran out of creative energy here ... \blindtext
\end{document}

Having said that, addresses, like my original comment about poetry, are really a special case where there are many social conventions about linebreaking. It's not unlikely that you end up having to specify linebreaks by hand in an address.

  • To clarify my context a bit, which I agree I should have done and almost did (but deleted because I was wanting to start off with a broad view): I'm mainly thinking about titles, subtitles, and other headings. – bbarker Apr 14 '14 at 2:38
  • 1
    @bbarker same comments apply, do you want to allow hyphenation, do you only want to allow manual line breaking? Why are your headings so long they need to linebreak:-) – David Carlisle Apr 14 '14 at 8:37
  • I'm mainly concerned with a semblance of balance for line lengths, which to me is important in some situations. I've added to my question above to reflect the original inspiration for this question - hope this clears things up. I'm wanting to avoid manual line breaking, or at least I'm curious if it is possible. Often times I will change something (e.g. in my CV slightly) which will require me to readjust line-breaks. Manual still may be the way to go in such a small and important document. Substitute "Coruscant" with "UK" and it looks even worse in my opinion. – bbarker Apr 14 '14 at 19:18
  • @bbarker the RaggedRight version is more likely to give balanced lien lengths than the standard raggedright as it doesn't allow infinite stretch in rightskip – David Carlisle Apr 14 '14 at 19:21
  • there may be 2 problems with this: one is that it is not centered, and the second is that it looks like this ( imgur.com/fJKS9KL ) when I do: \affil[2]{\protect \RaggedRight Order of the ... – bbarker Apr 14 '14 at 19:32

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.