Is there an equivalent of lipsum for shorter sections of text?

The sections of text generated by lipsum are generally several lines long. Is there a simple way to generate shorter segments of random (generic) text (other than typing it, of course)?

-

This is a home brewed macro called \loremlines. Call as \loremlines{number of lines}. Note differences in multi column texts.

% Split a box into two
\documentclass{article}
\usepackage{lipsum,multicol}
\begin{document}
\newbox\one
\newbox\two
\long\def\loremlines#1{%
\setbox\one=\vbox {%
Test.\footnote{a footnote}%
\lipsum\footnote{Another footnote.}%
}
\setbox\two=\vsplit\one to #1\baselineskip
\unvbox\two}
\begin{multicols}{2}
\small
\loremlines{16}
\end{multicols}
\begin{multicols}{2}
\small
\loremlines{16}
\end{multicols}
\loremlines{5}
\end{document}


The code works by placing the contents of a \lipsum command in a box and then splitting it, at n\baselineskip, where n is the number of lines.

-

You could copy and paste paragraphs of the desired length from http://www.blindtextgenerator.com/. Obviously, this is no LaTeX or packaged version.

Btw, if you'd want to stick with lipsum, it seems to me that \lipsum[66] and \lipsum[75] are the shortest paragraphs, each generating almost exactly four lines with article standard settings.

Here's how I counted the lines:

\documentclass{article}

\usepackage{lipsum,lineno}

\makeatletter
\renewcommand{\lips@par}% patching lipsum's the end-of-paragraph command
{\par\section{~~\the\c@linenumber}%extra space for ToC
\resetlinenumber}
\makeatother

\begin{document}

\tableofcontents

\linenumbers\noindent
\lipsum[1-150]

\end{document}


And then I went through the ToC by hand, i.e. by eye. LuaTeX probably could've done it automatically.

-
... and has moreorless the same functionality as lipsum.org – yo' Mar 17 '12 at 20:58
@tohecz: Yes, but a cleaner interface :) – doncherry Mar 17 '12 at 22:14

The blindtext-package offers some optional settings:

\documentclass[english]{article}
\usepackage{babel}
\usepackage[pangram]{blindtext}
\begin{document}
\Blindtext[5][3]%5 paragraphs, each 3 pangrams
\end{document}


Remark: The pangram option was introduced this January 2012 with version 2.0. Maybe you need an update.

-

Building upon the answer of @YiannisLazarides - if you want to use a shorter lipsum text in, say, a caption: you can "expand" the lipsum text, and then you can use the xstring package to obtain a substring for a given length of characters from that; called it \loremnchars, where \loremnchars[5]{255} will return first 255 characters of the 5th paragraph (\lipsum[5]):

\documentclass{article}

\usepackage[nopar]{lipsum}
\usepackage{xstring}
% http://tex.stackexchange.com/a/26808/2595
\makeatletter
\def\unpacklipsum#1#2#3{%
\count@=#1\relax
\def#3{}%
\loop\ifnum\count@<#2\relax
\edef#3{#3\csname lipsum@\romannumeral\count@\endcsname}%
\repeat}
\makeatother

\def\loremnchars[#1]#2{%
\unpacklipsum{#1}{#1}{\myunpacked}%
\StrMid{\myunpacked}{1}{#2}% same as \StrLeft{\myunpacked}{#2}
}

\usepackage{caption}

\begin{document}

\begin{center}
\captionof{figure}[justmy]{Just my image; \loremnchars[5]{255} ...}
\end{center}

\end{document}

-
Good solution. It might need a \protect in the caption though. – Yiannis Lazarides Mar 31 '14 at 18:41