6

Is there a command that would typeset a some text (one paragraph), and then only actually put out the first N lines as formatted. It would mean that the last word might actually only be the first part of a hyphenated word. I like to make samples of a font at different text/leading sizes, and such a command would make this easier and prettier.

I use Lualatex if that makes a difference.

\documentclass{article}
\usepackage{blindtext}

\newcommand\firstnlines[2]{% #2 % want to print first #1 lines of #2 here }

\begin{document} \begin{minipage}{3in} % set fontsize & baselineskip here \firstnlines{8}{\blindtext} \end{minipage} \end{document}

David Carlisle
  • 757,742
dedded
  • 2,236

1 Answers1

9

enter image description here

\documentclass{article}
\usepackage{blindtext}

\newcommand\firstnlines[2]{{% \splittopskip=\ht\strutbox \vbadness10000 \setbox0\vbox{{\strut#2}}% \setbox2\vsplit0 to #1\baselineskip \unvbox2 }}

\begin{document}

8 \begin{minipage}[t]{3in} % set fontsize & baselineskip here \firstnlines{8}{\blindtext} \end{minipage}

1 \begin{minipage}[t]{3in} % set fontsize & baselineskip here \firstnlines{1}{\blindtext} \end{minipage}

3 \begin{minipage}[t]{3in} % set fontsize & baselineskip here \firstnlines{3}{\blindtext} \end{minipage}

\end{document}

David Carlisle
  • 757,742