| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% This file is part of the package lipsum for use with LaTeX2e. |
| 4 |
% |
| 5 |
% Function: Access to 150 paragraphs of the well known Lorem Ipsum dummy text. |
| 6 |
% |
| 7 |
% This program may be distributed and/or modified under the |
| 8 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 9 |
% of this license or (at your option) any later version. |
| 10 |
% The latest version of this license is in |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 13 |
% version 2005/12/01 or later. |
| 14 |
% |
| 15 |
% Please send error reports and suggestions for improvements to |
| 16 |
% https://github.com/PhelypeOleinik/lipsum |
| 17 |
% |
| 18 |
\def\lipsumversion{2.7} |
| 19 |
\def\lipsumdate{2021-09-20} |
| 20 |
%<*driver> |
| 21 |
\ProvidesFile{lipsum.dtx}% |
| 22 |
[\lipsumdate\space v\lipsumversion\space |
| 23 |
Access to 150 of Lorem Ipsum dummy text] |
| 24 |
\documentclass{l3doc} |
| 25 |
\usepackage{xcolor} |
| 26 |
\usepackage{booktabs} |
| 27 |
\usepackage{tabularx} |
| 28 |
\usepackage{enumitem} |
| 29 |
\usepackage{tikz} |
| 30 |
\usetikzlibrary{positioning} |
| 31 |
\usepackage[a4paper, |
| 32 |
top=2cm, left=8.8cm, right=2cm, bottom=3cm, |
| 33 |
marginparwidth=6.3cm, marginparsep=.5cm, |
| 34 |
]{geometry} |
| 35 |
\newlength\fullmargin |
| 36 |
\setlength\fullmargin\marginparwidth |
| 37 |
\addtolength\fullmargin\marginparsep |
| 38 |
\usepackage{mdframed} |
| 39 |
\mdfdefinestyle{expl}{% |
| 40 |
backgroundcolor=black!5!white, |
| 41 |
linewidth=0pt, |
| 42 |
middlelinewidth=0pt |
| 43 |
} |
| 44 |
\newmdenv[style=expl]{explbox} |
| 45 |
|
| 46 |
\usepackage{lipsum,multicol} |
| 47 |
\usepackage{multirow} |
| 48 |
\usepackage[latin, english]{babel} |
| 49 |
\makeatletter |
| 50 |
\newcommand\@subtitle{} |
| 51 |
\newcommand\subtitle[1]{% |
| 52 |
\renewcommand\@subtitle{#1}} |
| 53 |
\renewcommand\maketitle[1]{% |
| 54 |
\noindent |
| 55 |
\hspace{-\fullmargin}% |
| 56 |
\begin{minipage}{\textwidth+\fullmargin} |
| 57 |
\renewcommand\thefootnote{\fnsymbol{footnote}} |
| 58 |
\let\thanks\footnote |
| 59 |
{ |
| 60 |
\centering |
| 61 |
{\LARGE \@title}\\[.8\baselineskip] |
| 62 |
{\LARGE \@subtitle}\\[2\baselineskip] |
| 63 |
{\Large \@author}\\[\baselineskip] |
| 64 |
{\Large \@date}\\[\baselineskip] |
| 65 |
} |
| 66 |
\ifx\\#1\\\else |
| 67 |
\begin{multicols}{2}[% |
| 68 |
\subsection*{\hfill\abstractname\hfill\null}] |
| 69 |
\setlength{\columnsep}{.5cm}% |
| 70 |
#1 |
| 71 |
\end{multicols} |
| 72 |
\fi |
| 73 |
\end{minipage}} |
| 74 |
\makeatother |
| 75 |
\newenvironment{wide} |
| 76 |
{\hspace{-.75\fullmargin}% |
| 77 |
\begin{minipage}{\textwidth+.75\fullmargin}} |
| 78 |
{\end{minipage}} |
| 79 |
\newcommand\opt[1]{\textsf{#1}} % l3doc does not have some markup for package options... |
| 80 |
\newcommand\lips{\emph{Lorem ipsum\ldots}} |
| 81 |
\renewcommand\topfraction{.85} |
| 82 |
\renewcommand\textfraction{.15} |
| 83 |
\renewcommand\floatpagefraction{.85} |
| 84 |
\emergencystretch 2em |
| 85 |
\newcommand\secref[1]{(see section~\ref{#1})} |
| 86 |
\usepackage{hyperref} |
| 87 |
\def\ghissue#1{% |
| 88 |
\texttt{\##1}\footnote{% |
| 89 |
\url{https://github.com/PhelypeOleinik/lipsum/issues/#1}}} |
| 90 |
\begin{document} |
| 91 |
\DocInput{lipsum.dtx} |
| 92 |
\end{document} |
| 93 |
%</driver> |
| 94 |
%<*package> |
| 95 |
\NeedsTeXFormat{LaTeX2e} |
| 96 |
\RequirePackage{l3keys2e} |
| 97 |
\@ifundefined{NewDocumentCommand} |
| 98 |
{\RequirePackage{xparse}}{} |
| 99 |
\ProvidesExplPackage {lipsum} {\lipsumdate} {\lipsumversion} |
| 100 |
{150 paragraphs of Lorem Ipsum dummy text} |
| 101 |
%</package> |
| 102 |
% \fi |
| 103 |
% |
| 104 |
% \title{\pkg{lipsum}} |
| 105 |
% \subtitle{Access to 150 paragraphs of Lorem Ipsum dummy |
| 106 |
% text\thanks{Version: \lipsumversion}^^A |
| 107 |
% \thanks{Since March 2021, Phelype Oleinik maintains this package |
| 108 |
% (\href{mailto:[email protected]} |
| 109 |
% {phelype.oleinik\meta{at}latex-project.org}).}} |
| 110 |
% \author{Patrick Happel\thanks{[email protected]}} |
| 111 |
% \date{\today} |
| 112 |
% \RecordChanges |
| 113 |
% \changes{v1.0}{2004/05/15}{First release} |
| 114 |
% \changes{v1.1}{2011/02/08}{Added support for typesetting dummy text without |
| 115 |
% paragraphs in between.} |
| 116 |
% \changes{v1.2}{2011/04/14}{Bug fix (thanks to Florent Chervet and Ulrike |
| 117 |
% Fischer for reporting).} |
| 118 |
% \changes{v1.3}{2014/07/19}{Introduced some improvements and provided some |
| 119 |
% new macros (thanks to tex.stackexchange user egreg).} |
| 120 |
% \changes{v1.3a}{2017/08/10}{Fixed a type in the documentation (thanks to |
| 121 |
% Vincent Belaïche). This version never made its way on CTAN due to some |
| 122 |
% version naming conflicts. Since the change here was only in the |
| 123 |
% documentation, I first didn't want it to be 1.3a and later had no time to |
| 124 |
% update it properly.} |
| 125 |
% \changes{v2.0}{2018/11/07}{Added the possibility to fetch a number of sentences from the |
| 126 |
% lipsum paragraphs (thanks to Frank Mittelbach).} |
| 127 |
% \changes{v2.0}{2018/11/07}{Rewritten code in \pkg{expl3} syntax.} |
| 128 |
% \changes{v2.1}{2018/11/18}{Changed defaults, now nothing is typeset at the |
| 129 |
% end of any list.} |
| 130 |
% \changes{v2.1a}{2018/11/24}{Added forgotten ins-file to CTAN. This requires |
| 131 |
% a new version number.} |
| 132 |
% \changes{v2.2}{2018/12/25}{replaced \cs{tex_par:D} by \cs{par} to avoid |
| 133 |
% incompatibilities with \LaTeX2e's |list|-environment. Thanks to Karl Hagen |
| 134 |
% for reporting. See \url{ttps://github.com/patta42/lipsum/issues/12}.} |
| 135 |
% \changes{v2.3}{2021/03/03}{Remove dependency on an \pkg{xparse} internal |
| 136 |
% macro. \pkg{lipsum}'s new home at |
| 137 |
% \url{https://github.com/PhelypeOleinik/lipsum}} |
| 138 |
% \changes{v2.4}{2021/06/03}{Major changes documented in \texttt{CHANGELOG.md}.} |
| 139 |
% |
| 140 |
% \maketitle{\pkg{lipsum} is a \LaTeX{} package that produces dummy text |
| 141 |
% to be used in test documents or examples. The paragraphs are taken with |
| 142 |
% permission from \url{https://www.lipsum.com/}, thanks to James Wilson for |
| 143 |
% this work. Furthermore, the following people contributed to \pkg{lipsum} by |
| 144 |
% suggesting improvements, correcting bugs or finding typos in the |
| 145 |
% documentation: Florent Chervet, Ulrike Fischer, Vincent Belaïche, Enrico |
| 146 |
% Gregorio, Frank Mittelbach, Karl Hagen. |
| 147 |
% |
| 148 |
% Please, file bug reports, typos in the documentation or |
| 149 |
% feature requests as an issue on |
| 150 |
% \url{https://github.com/PhelypeOleinik/lipsum/issues}.} |
| 151 |
% |
| 152 |
% \begin{documentation} |
| 153 |
% |
| 154 |
% \section{Introduction} |
| 155 |
% |
| 156 |
% To load the package, write |
| 157 |
% \begin{verbatim} |
| 158 |
% \usepackage{lipsum} |
| 159 |
% \end{verbatim} |
| 160 |
% in the preamble of your document. Probably the most important macro |
| 161 |
% provided by this package is \DescribeMacro{\lipsum}\cs{lipsum}, which |
| 162 |
% typesets the \emph{Lorem ipsum} paragraphs. The first optional |
| 163 |
% argument allows to specify the range of the paragraphs. For example, |
| 164 |
% \verb|\lipsum[4-57]| typesets the paragraphs 4 to 57 and accordingly, |
| 165 |
% \verb|\lipsum[23]| typesets the 23\textsuperscript{rd} paragraph. |
| 166 |
% Using \cs{lipsum} without its optional argument typesets the |
| 167 |
% paragraphs 1--7 of \lips |
| 168 |
% |
| 169 |
% As of version 2.0, \cs{lipsum} has a second optional argument which allows |
| 170 |
% selecting a range of sentences from the paragraphs. To get the sentences |
| 171 |
% four to eight from paragraphs three to nine, use |\lipsum[3-9][4-8]|. |
| 172 |
% The sentences are counted from the first sentence of the first selected |
| 173 |
% paragraph. In the previous example, sentence number~1 is the first |
| 174 |
% sentence of paragraph number~3. |
| 175 |
% |
| 176 |
% \subsection{Foreword to Version 2.4} |
| 177 |
% \label{sec:foreword2.4} |
| 178 |
% |
| 179 |
% Version~2.4 received another almost complete rewrite focussing on the |
| 180 |
% internal structure of the package, and some minor fixes (see the |
| 181 |
% \texttt{CHANGELOG} for more details). |
| 182 |
% |
| 183 |
% The package now ships with a new dummy text, in pseudo-Czech, provided |
| 184 |
% by Ondřej Macek. To select this text, load the package with |
| 185 |
% |\usepackage[text=lipsum-cs]{lipsum}| or use |
| 186 |
% \cs{setlipsum}|{text=lipsum-cs}|. |
| 187 |
% |
| 188 |
% The dummy texts now have a language metadata which is used to select |
| 189 |
% the proper hyphenation patterns to the dummy text. For compatibility |
| 190 |
% with old documents you can load \pkg{lipsum} with |
| 191 |
% |\usepackage[auto-lang=false]{lipsum}| or, as above, use |
| 192 |
% \cs{setlipsum}|{auto-lang=false}|. |
| 193 |
% |
| 194 |
% Finally, as demonstrated above, a new macro \cs{setlipsum} was added |
| 195 |
% to change package options anywhere in the document, so you may change, |
| 196 |
% for example, the dummy text printed by \cs{lipsum} on-the-fly by using |
| 197 |
% \cs{setlipsum}|{text=|\meta{name}|}| \secref{sec:other-texts} for a |
| 198 |
% list of available texts). In general, a key-val syntax was added which |
| 199 |
% will eventually replace the command-based syntax for package settings. |
| 200 |
% For the time being, both versions are available. |
| 201 |
% |
| 202 |
% \subsection{Foreword to Version 2.0}\label{sec:foreword2.0} |
| 203 |
% |
| 204 |
% Version 2.0 of \pkg{lipsum} is a complete (well, nearly complete) rewrite |
| 205 |
% of the code in \pkg{expl3} |
| 206 |
% syntax. I have never used \pkg{expl3} before and thus the code might be too |
| 207 |
% complicated, might use wrong or badly chosen data types or weird function |
| 208 |
% names. I am happy to receive comments on this. |
| 209 |
% |
| 210 |
% Due the complete rewrite, some internals have changed which might impact |
| 211 |
% older documents. Since, however, I guess that \pkg{lipsum} is not used for |
| 212 |
% documents with true, important, content, I think potentially breaking up old |
| 213 |
% documents is not a big issue here. The changes are: |
| 214 |
% \begin{itemize} |
| 215 |
% \item The package option \opt{nopar} now uses a \cs{space} as terminator, |
| 216 |
% instead of \cs{relax}. |
| 217 |
% \item The commands \cs{UnpackLipsum} and \cs{UnpackLipsum*} are no longer |
| 218 |
% available. The effect of \cs{UnpackLipsum} now is default for |
| 219 |
% \cs{unpacklipsum} (or \cs{unpacklipsum*}, depending on the package |
| 220 |
% option). The effect of \cs{UnpackLipsum*} can be mimicked by using |
| 221 |
% \cs{LipsumProtect}\Arg{command}, as in the following example: |
| 222 |
% \begin{explbox} |
| 223 |
% \begin{verbatim} |
| 224 |
% \documentclass{article} |
| 225 |
% \usepackage{lipsum,xcolor} |
| 226 |
% \newcommand\foo{} |
| 227 |
% \SetLipsumParListItemEnd{\LipsumProtect{\foo}} |
| 228 |
% |
| 229 |
% \begin{document} |
| 230 |
% \renewcommand\foo{\color{.!75!red}} |
| 231 |
% { \lipsumexp } |
| 232 |
% |
| 233 |
% \newcounter{mycnt}\setcounter{mycnt}{1} |
| 234 |
% \renewcommand\foo{% |
| 235 |
% (\themycnt)\stepcounter{mycnt}} |
| 236 |
% \lipsumexp |
| 237 |
% \end{document} |
| 238 |
% \end{verbatim} |
| 239 |
% \end{explbox} |
| 240 |
% \item The internal macros \cs{lips@i}, \cs{lips@ii}, \cs{lips@iii}, \ldots, |
| 241 |
% \cs{lips@cl} are no longer available. |
| 242 |
% \item All other internal macros (with one exception) are no longer available, |
| 243 |
% too. |
| 244 |
% \end{itemize} |
| 245 |
% |
| 246 |
% \subsection{Foreword to version 2.2} |
| 247 |
% |
| 248 |
% As of version 2.2, \pkg{lipsum} provides a simple interface to define other |
| 249 |
% texts to be used as output of the \cs{lipsum}-family of commands. This was |
| 250 |
% heavily inspired by an issue raised by |
| 251 |
% \emph{svenper} on |
| 252 |
% github\footnote{\url{https://github.com/patta42/lipsum/issues/13}}. However, |
| 253 |
% the implementation of this interface might not match the needs of everyone |
| 254 |
% who wants to provide a dummy text in another language. Comments and |
| 255 |
% suggestions on this are very welcome. |
| 256 |
% |
| 257 |
% Please note that the documentation still only refers to the |
| 258 |
% \emph{Lorem ipsum} text. |
| 259 |
% |
| 260 |
% \section{Usage} |
| 261 |
% |
| 262 |
% \pkg{lipsum} was intended to quickly provide a way to fill a page or two to |
| 263 |
% analyze the page |
| 264 |
% layout\footnote{\url{https://groups.google.com/d/topic/de.comp.text.tex/oPeLOjkrLfk}}. |
| 265 |
% While it has grown in the meanwhile and now provides some more advanced |
| 266 |
% features, it still is only intended to quickly provide text. If you want more |
| 267 |
% features, look at the \pkg{blindtext}-package. |
| 268 |
% |
| 269 |
% \subsection{Package Options} |
| 270 |
% \label{sec:pkg-opt} |
| 271 |
% |
| 272 |
% \pkg{lipsum} outputs a range of paragraphs taken from the \lips\ dummy |
| 273 |
% text. The package options control mainly the behaviour of the |
| 274 |
% \cs{lipsum} and \cs{unpacklipsum} commands, and can be set at |
| 275 |
% load-time with \cs{usepackage}|[|\meta{option}|]{lipsum}|, or later in |
| 276 |
% the document by using \cs{setlipsum}|{|\meta{option}|}|. |
| 277 |
% |
| 278 |
% \begingroup |
| 279 |
% \RenewDocumentCommand \item { r[] e= d() } |
| 280 |
% {\par\medskip\noindent\llap |
| 281 |
% {\smash{\begin{tabular}{@{}l@{}}\toprule |
| 282 |
% \opt{#1}\\\bottomrule\end{tabular}}~~}%^^A |
| 283 |
% \IfValueT{#2}{=~~\!\meta{#2}\hfill |
| 284 |
% \IfValueT{#3}{\quad(default: \texttt{#3})}\null |
| 285 |
% \newline}\ignorespaces} |
| 286 |
% |
| 287 |
% \item[nopar]={boolean}(false) |
| 288 |
% Changes the initial default separator between each paragraph of |
| 289 |
% \cs{lipsum} from \cs{par} to \cs{space}, and the other way around |
| 290 |
% for \cs{lipsum*}. |
| 291 |
% \item[text]={name}(lipsum) |
| 292 |
% Selects the dummy text \meta{name} that is used by \cs{lipsum} and |
| 293 |
% \cs{unpacklipsum} \secref{sec:other-texts}. |
| 294 |
% \item[language]={lang}(latin) |
| 295 |
% Sets the language to be used by \cs{lipsum} to typeset the currently |
| 296 |
% active dummy text \secref{sec:hyphenation}. Changing the dummy text |
| 297 |
% with the \opt{text} option will also change the current |
| 298 |
% \opt{language}. |
| 299 |
% \item[auto-lang]={boolean}(true) |
| 300 |
% Turns on/off automatic language switching. This changed since |
| 301 |
% version 2.3, in which this option (didn't exist thus) was |false| by |
| 302 |
% default. See section~\ref{sec:hyphenation} for more details. |
| 303 |
% \item[default-range]={p_i\texttt{-}p_f}(1-7) |
| 304 |
% Sets the default range of paragraphs produced by \cs{lipsum} when no |
| 305 |
% optional argument is provided. The value to \opt{default-range} |
| 306 |
% obeys the \meta{range} syntax described in |
| 307 |
% section~\ref{sec:range-syntax}. If no value is given to |
| 308 |
% \opt{default-range} (that is, \cs{setlipsum}|{default-range}|), then |
| 309 |
% the default is reset to |1-7|. |
| 310 |
% |
| 311 |
% \endgroup |
| 312 |
% |
| 313 |
% \medskip |
| 314 |
% |
| 315 |
% Besides these options, there are still ones that can be passed to the |
| 316 |
% package to influence the paragraph and sentence separators and other |
| 317 |
% such things. These options are detailed in |
| 318 |
% section~\ref{sec:separators}. |
| 319 |
% |
| 320 |
%^^A Besides the listed options, there are still options that can be |
| 321 |
%^^A passed to the package to influence the paragraph and sentence |
| 322 |
%^^A separators and other things like that. The options for paragraphs |
| 323 |
%^^A are: |
| 324 |
%^^A \AddToHookNext{env/multicols/before} |
| 325 |
%^^A {\setlength{\multicolsep}{0.5\multicolsep}} |
| 326 |
%^^A \begin{multicols}{2} |
| 327 |
%^^A \ttfamily \setlist{nosep} |
| 328 |
%^^A \begin{itemize} |
| 329 |
%^^A \item par-before |
| 330 |
%^^A \item par-begin |
| 331 |
%^^A \item par-sep |
| 332 |
%^^A \item par-end |
| 333 |
%^^A \item par-after |
| 334 |
%^^A \end{itemize} |
| 335 |
%^^A \begin{itemize} |
| 336 |
%^^A \item par-before* |
| 337 |
%^^A \item par-begin* |
| 338 |
%^^A \item par-sep* |
| 339 |
%^^A \item par-end* |
| 340 |
%^^A \item par-after* |
| 341 |
%^^A \end{itemize} |
| 342 |
%^^A \end{multicols} |
| 343 |
%^^A and for sentences, the same group with |sentence| instead of |par| |
| 344 |
%^^A in their name. These options are detailed in |
| 345 |
%^^A section~\ref{sec:separators}. |
| 346 |
% |
| 347 |
% \subsection{User Commands} |
| 348 |
% |
| 349 |
% \begin{function}{\lipsum} |
| 350 |
% \begin{syntax} |
| 351 |
% \cs{lipsum}\meta{*}\oarg{par range}\oarg{sentence range} |
| 352 |
% \end{syntax} |
| 353 |
% \cs{lipsum} outputs the \meta{par range} from the |
| 354 |
% currently active dummy text. If \meta{par range} is not given |
| 355 |
% or is empty, the \opt{default-range} (initially |1-7|) is output. |
| 356 |
% ^^A |
| 357 |
% If a \meta{sentence range} is given, the selected paragraphs are |
| 358 |
% split into sentences, numbered starting from~1, and the specified |
| 359 |
% range of sentences is taken out from those paragraphs. |
| 360 |
% ^^A |
| 361 |
% If the \meta{*} version is used, a different set of separators is |
| 362 |
% inserted around the paragraphs or sentences. |
| 363 |
% |
| 364 |
% \cs{lipsum} changes the active language to that of the dummy text |
| 365 |
% for typesetting, so the proper hyphenation patterns are used. |
| 366 |
% See section~\ref{sec:hyphenation}. |
| 367 |
% ^^A |
| 368 |
% Section~\ref{sec:range-syntax} explains the syntax of ranges, and |
| 369 |
% section~\ref{sec:separators} explains the separators added around |
| 370 |
% the pieces of text. |
| 371 |
% \end{function} |
| 372 |
% |
| 373 |
% \begin{function}{\unpacklipsum,\lipsumexp} |
| 374 |
% \begin{syntax} |
| 375 |
% \cs{unpacklipsum}\meta{*}\oarg{par range}\oarg{sentence range} |
| 376 |
% \ldots |
| 377 |
% \cs{lipsumexp} |
| 378 |
% \end{syntax} |
| 379 |
% \cs{unpacklipsum} selects the paragraphs and/or sentences exactly as |
| 380 |
% described for \cs{lipsum}, but instead of outputting them, it saves |
| 381 |
% the selected text in the \cs{lipsumexp} macro. Additionally, |
| 382 |
% \cs{unpacklipsum} \ldots\cs{lipsumexp} is not completely equivalent |
| 383 |
% to \cs{lipsum} because it doesn't change languages as \cs{lipsum} |
| 384 |
% does. |
| 385 |
% \end{function} |
| 386 |
% |
| 387 |
% \begin{function}{\setlipsum} |
| 388 |
% \begin{syntax} |
| 389 |
% \cs{setlipsum}\Arg{key-val list} |
| 390 |
% \end{syntax} |
| 391 |
% Applies the \meta{key-val list} of options to the package. The |
| 392 |
% options are described in section~\ref{sec:pkg-opt} and in |
| 393 |
% section~\ref{sec:separators}. |
| 394 |
% \end{function} |
| 395 |
% |
| 396 |
% \subsection{Other commands} |
| 397 |
% |
| 398 |
% These commands exist for necessity or backwards comatibility, and |
| 399 |
% should normally not be needed in user documents. |
| 400 |
% |
| 401 |
% \begin{function}{\SetLipsumText} |
| 402 |
% \begin{syntax} |
| 403 |
% \cs{SetLipsumDefault}\Arg{name} |
| 404 |
% \end{syntax} |
| 405 |
% Loads the dummy text \meta{name} \secref{sec:other-texts}. |
| 406 |
% This command does the same as option \opt{text}, but it is |
| 407 |
% kept for backwards compatibility. |
| 408 |
% \end{function} |
| 409 |
% |
| 410 |
% \begin{function}{\SetLipsumDefault} |
| 411 |
% \begin{syntax} |
| 412 |
% \cs{SetLipsumDefault}\Arg{range} |
| 413 |
% \end{syntax} |
| 414 |
% Sets the default range for \cs{lipsum} and \cs{unpacklipsum}. |
| 415 |
% This command does the same as option \opt{default-range}, but it is |
| 416 |
% kept for backwards compatibility. |
| 417 |
% \end{function} |
| 418 |
% |
| 419 |
% \section{General remarks on behaviour} |
| 420 |
% |
| 421 |
% Here are some topics that are general considerations about the |
| 422 |
% behaviour of \pkg{lipsum} and its commands. These are technicalities |
| 423 |
% that most end users don't care too much about, unless you are trying |
| 424 |
% to do something beyond the usual ``print me some dummy text''. |
| 425 |
% |
| 426 |
% \subsection{Syntax of paragraph and sentence ranges} |
| 427 |
% \label{sec:range-syntax} |
| 428 |
% |
| 429 |
% A \meta{range} argument can either be blank, a single integer, or a |
| 430 |
% proper integer range. If the \meta{range} argument is blank, the |
| 431 |
% commands behave as if the argument was not given at all. For example, |
| 432 |
% |\lipsum[]| behaves exaclty like |\lipsum| and outputs the default |
| 433 |
% paragraph range. Note that |\lipsum[][2-5]| does \textbf{not} behave |
| 434 |
% as |\lipsum[2-5]|, but behaves as |\lipsum[1-7][2-5]| (assuming |
| 435 |
% |default=range=1-7|), because the default value is then taken for the |
| 436 |
% first argument. If the \meta{range} argument is an integer, then only |
| 437 |
% a single paragraph/sentence is selected. |
| 438 |
% |
| 439 |
% If the argument contains a |-| (\textsc{ascii}~45), it is interpreted |
| 440 |
% as a \emph{proper} range \meta{n_i}|-|\meta{n_f}. In a proper range, |
| 441 |
% if \meta{n_i} is blank, it is taken to be the start of the possible |
| 442 |
% range, and in the same way, if \meta{n_f} is empty it is taken to be |
| 443 |
% the end of the possible range. That is, |\lipsum[-9]| is the same as |
| 444 |
% |\lipsum[1-9]|, and |\lipsum[5-]| is the same (assuming the standard |
| 445 |
% 150-paragraph dummy text) as |\lipsum[5-150]|, and similarly, |
| 446 |
% |\lipsum[-]| is the same as |\lipsum[1-150]|. |
| 447 |
% |
| 448 |
% Only one |-| is allowed in a range, so if more than one |-| is given, |
| 449 |
% an error is raised and no paragraphs/sentences are output. No |
| 450 |
% paragraphs or sentences will be output also in case one of the ranges |
| 451 |
% is reversed, so |\lipsum[2-1]| returns no paragraphs, as does |
| 452 |
% |\lipsum[][2-1]| output no sentences, for example. Note that |
| 453 |
% ``returning no paragraphs/sentences'' is not ``the output is empty'': |
| 454 |
% that is mostly true, except that the |-before| and |-after| separators |
| 455 |
% are still output \secref{sec:separators}. |
| 456 |
% |
| 457 |
% Finally, if a range spans more paragraphs or sentences than what the |
| 458 |
% dummy text actually provides, the range is truncated so that it fits |
| 459 |
% the available text. If the range in the argument does not intersect |
| 460 |
% with the range provided by the dummy text, no paragraphs or sentences |
| 461 |
% are output. |
| 462 |
% |
| 463 |
% \subsection{Hyphenation patterns} |
| 464 |
% \label{sec:hyphenation} |
| 465 |
% |
| 466 |
% Since version~2.4, the command \cs{lipsum} automatically changes the |
| 467 |
% hyphenation patterns when typesetting a dummy text, so that |
| 468 |
% line-breaking looks better \secref{sec:foreword2.4}. This feature is |
| 469 |
% on by default, so if you need the old behaviour you have to explicitly |
| 470 |
% disable automatic language switching with |
| 471 |
% |\setlipsum{auto-lang=false}|. |
| 472 |
% |
| 473 |
% The language is defined individually for each dummy text |
| 474 |
% \secref{sec:other-texts}, but you may change it for the current dummy |
| 475 |
% text by using |\setlipsum{language=|\meta{lang}|}|. If you load |
| 476 |
% another dummy text (for example with the \opt{text} option), then the |
| 477 |
% option \opt{language} is also changed according to the dummy text |
| 478 |
% loaded \secref{sec:other-texts}. |
| 479 |
% |
| 480 |
% \subsection{Paragraph and sentence separators} |
| 481 |
% \label{sec:separators} |
| 482 |
% |
| 483 |
% As may be clear by now, \pkg{lipsum} has two modes of operation: |
| 484 |
% sentence output, and paragraph output, selected by providing or not |
| 485 |
% providing the second optional argument to \cs{lipsum}. In each mode, |
| 486 |
% the dummy text is separated into chunks (paragraphs or sentences), |
| 487 |
% which are counted, and then output accordingly. |
| 488 |
% |
| 489 |
% When \cs{lipsum} (or \cs{unpacklipsum}) is used with a single (or no) |
| 490 |
% optional argument, then a range of paragraphs is output, along with |
| 491 |
% some ``separators'' (in the lack of a better name) between paragraphs, |
| 492 |
% around each paragraph, and before and after the whole output. |
| 493 |
% A schematic (very colorful, because I couldn't find a better visual) |
| 494 |
% representation of the output is: |
| 495 |
% |
| 496 |
% \begin{function}{ |
| 497 |
% par-before, |
| 498 |
% par-begin, |
| 499 |
% par-sep, |
| 500 |
% par-end, |
| 501 |
% par-after, |
| 502 |
% sentence-before, |
| 503 |
% sentence-begin, |
| 504 |
% sentence-sep, |
| 505 |
% sentence-end, |
| 506 |
% sentence-after, |
| 507 |
% } |
| 508 |
% \noindent |
| 509 |
% \begin{tikzpicture}[x=0.703cm, |
| 510 |
% item/.style={ |
| 511 |
% draw, |
| 512 |
% rounded corners=2mm, |
| 513 |
% minimum width=2.2cm, |
| 514 |
% execute at begin node=\strut, |
| 515 |
% rotate=54, |
| 516 |
% font=\footnotesize, |
| 517 |
% }, |
| 518 |
% ] |
| 519 |
% \def\sep#1{\texttt{par-\textbf{#1}}\null} |
| 520 |
% \node [item,fill=red!40 ] at (0 ,0) {\sep{before}}; |
| 521 |
% \node [item,fill=red!20 ] at (1 ,0) {\sep{begin }}; |
| 522 |
% \node [item,fill=red!20 ] at (2 ,0) {\meta{paragraph}}; |
| 523 |
% \node [item,fill=red!20 ] at (3 ,0) {\sep{end \ }}; |
| 524 |
% \node [item,shading=axis,left color=red!30,right color=green!30, |
| 525 |
% shading angle=54] at (4 ,0) {\sep{sep \ }}; |
| 526 |
% \node [item,fill=green!20] at (5 ,0) {\sep{begin }}; |
| 527 |
% \node [item,fill=green!20] at (6 ,0) {\meta{paragraph}}; |
| 528 |
% \node [item,fill=green!20] at (7 ,0) {\sep{end \ }}; |
| 529 |
% \node [item,shading=axis,left color=green!30,right color=blue!30, |
| 530 |
% shading angle=54] at (8 ,0) {\sep{sep \ }}; |
| 531 |
% \node [item,fill=blue!20 ] at (9 ,0) {\sep{begin }}; |
| 532 |
% \node [item,fill=blue!20 ] at (10,0) {\meta{paragraph}}; |
| 533 |
% \node [item,fill=blue!20 ] at (11,0) {\sep{end \ }}; |
| 534 |
% \node [item,fill=blue!40 ] at (12,0) {\sep{after\ }}; |
| 535 |
% \end{tikzpicture} |
| 536 |
% |
| 537 |
% When \cs{lipsum} is called, the first thing it outputs is the |
| 538 |
% \opt{par-before} tokens. These tokens are output unconditionally, |
| 539 |
% regardless of how many (if any) paragraph is output. |
| 540 |
% |
| 541 |
% Then, before each paragraph in the range, \cs{lipsum} outputs the |
| 542 |
% \opt{par-begin} tokens, and then the actual text of the |
| 543 |
% \meta{paragraph}, and then the \opt{par-end} tokens. These tokens are |
| 544 |
% output conditionally, if the paragraph text is output. If more than |
| 545 |
% one paragraph is output, then the \opt{par-sep} tokens are inserted |
| 546 |
% between the \opt{par-end} of one paragraph and the \opt{par-begin} of |
| 547 |
% the paragraph that follows. |
| 548 |
% |
| 549 |
% \end{function} |
| 550 |
% |
| 551 |
% Finally, at the end, the \opt{par-after} tokens are inserted |
| 552 |
% unconditionally at the end, same as for \opt{par-before}. |
| 553 |
% |
| 554 |
% As mentioned before, in case of an error parsing the range, the output |
| 555 |
% will be no paragraphs, but the \opt{par-before} and \opt{par-after} |
| 556 |
% tokens are still output. |
| 557 |
% |
| 558 |
% The explanation above is equally valid for the starred variants. If |
| 559 |
% \cs{lipsum}|*| is used, the \opt{par-before*} tokens are |
| 560 |
% inserted, and so on. It is also true for sentences (starred or |
| 561 |
% otherwise), replacing |par| in the option names by |sentence|, so when |
| 562 |
% you use, for example, |\lipsum[][1-9]|, the \opt{sentence-before} |
| 563 |
% tokens will be unconditionally inserted, and so on. |
| 564 |
% |
| 565 |
% Note that, when \cs{lipsum} is used in sentence-mode (for example, |
| 566 |
% with |\lipsum[1-3][1-9]|), only the |sentence-...| tokens are inserted |
| 567 |
% in the output, regardless of how many paragraphs those sentences were |
| 568 |
% collected from. In the same way, if paragraph-mode is being used, only |
| 569 |
% |par-...| tokens are inserted. |
| 570 |
% |
| 571 |
% \subsubsection{Deprecated command-based syntax} |
| 572 |
% |
| 573 |
% Older versions of \pkg{lipsum} (from 2.0 to 2.3) provided~10 CamelCase |
| 574 |
% commands for changing the separators, but the syntax was rather |
| 575 |
% cumbersome to use, so the keyval syntax presented thus far was |
| 576 |
% introduced in the hopes of making things a bit easier. The old |
| 577 |
% commands will still exist for some time in the package, but with a |
| 578 |
% deprecation warning. Changing to the keyval syntax is advised, so |
| 579 |
% here is a correspondence table between the old and new syntaxes: |
| 580 |
% |
| 581 |
% \begin{center} |
| 582 |
% \ttfamily \makeatletter |
| 583 |
% \definecolor{a}{HTML}{E0211A}\colorlet{a}{a!60!black} |
| 584 |
% \definecolor{b}{HTML}{5970D5}\colorlet{b}{b!60!black} |
| 585 |
% \protected@edef\x#1#2{\string\SetLipsum |
| 586 |
% {\color{a}#1}List{\color{b}#2}}% |
| 587 |
% \def\y#1#2{{\color{a}#1}-{\color{b}#2}} |
| 588 |
% \begin{tabular}{@{}ll@{}} |
| 589 |
% \toprule |
| 590 |
% \textrm{Old command} & \textrm{New key name} \\ |
| 591 |
% \midrule |
| 592 |
% \x{Par}{Start} & \y{par}{before} \\ |
| 593 |
% \x{Par}{ItemStart} & \y{par}{begin} \\ |
| 594 |
% \x{Par}{ItemSeparator} & \y{par}{sep} \\ |
| 595 |
% \x{Par}{ItemEnd} & \y{par}{end} \\ |
| 596 |
% \x{Par}{End} & \y{par}{after} \\ |
| 597 |
% \x{Sentence}{Start} & \y{sentence}{before} \\ |
| 598 |
% \x{Sentence}{ItemStart} & \y{sentence}{begin} \\ |
| 599 |
% \x{Sentence}{ItemSeparator} & \y{sentence}{sep} \\ |
| 600 |
% \x{Sentence}{ItemEnd} & \y{sentence}{end} \\ |
| 601 |
% \x{Sentence}{End} & \y{sentence}{after} \\ |
| 602 |
% \bottomrule |
| 603 |
% \end{tabular} |
| 604 |
% \end{center} |
| 605 |
% |
| 606 |
% Additionally, the command-based interface provided shortcuts |
| 607 |
% |\SetLipsum|\meta{Thing}|List|(|Item|)|Surrounders|, which are |
| 608 |
% equivalent to just using the commands |
| 609 |
% |\SetLipsum|\meta{Thing}|List|(|Item|)|Start| then |\...End|. These |
| 610 |
% don't provide any functionality, other than requiring a little less |
| 611 |
% typing, so no key-val alternative was implemented. |
| 612 |
% The |\...|\meta{Thing}|...Surrounders| commands should be replaced by |
| 613 |
% \meta{thing}|-before| and \meta{thing}|-after|, and the |
| 614 |
% |\...|\meta{Thing}|...ItemSurrounders| commands should be replaced by |
| 615 |
% \meta{thing}|-begin| and \meta{thing}|-end|, as in the correspondence |
| 616 |
% table below: |
| 617 |
% |
| 618 |
% \begin{center} |
| 619 |
% \ttfamily \makeatletter |
| 620 |
% \definecolor{a}{HTML}{E0211A}\colorlet{a}{a!60!black} |
| 621 |
% \definecolor{b}{HTML}{5970D5}\colorlet{b}{b!60!black} |
| 622 |
% \protected@edef\x#1#2{\string\SetLipsum |
| 623 |
% {\color{a}#1}List{\color{b}#2}Surrounders%^^A |
| 624 |
% \kern .5\tabcolsep \xleaders\hbox{\vrule |
| 625 |
% width 2pt height \dimexpr .5ex+.4pt\relax depth -.5ex |
| 626 |
% \kern 2pt}% |
| 627 |
% \hskip 0pt plus 1filll \kern -.5\tabcolsep |
| 628 |
% \raise.5ex\rlap{\kern.5\tabcolsep |
| 629 |
% \vrule width \tabcolsep height 0.4pt depth 0pt |
| 630 |
% \kern-0.5\tabcolsep |
| 631 |
% \smash{\vrule depth \normalbaselineskip width 0.4pt |
| 632 |
% \raise-\normalbaselineskip |
| 633 |
% \hbox{\vrule width .5\tabcolsep height 0.4pt depth 0pt}}}}% |
| 634 |
% \def\y#1#2{{\color{a}#1}-{\color{b}#2}} |
| 635 |
% \begin{tabular}{@{}ll@{}} |
| 636 |
% \toprule |
| 637 |
% \textrm{Old command} & \textrm{New key names} \\ |
| 638 |
% \midrule |
| 639 |
% \x{Par}{} & \y{par}{}before \\ |
| 640 |
% & \y{par}{}after \\ |
| 641 |
% \x{Par}{Item} & \y{par}{begin} \\ |
| 642 |
% & \y{par}{end} \\ |
| 643 |
% \x{Sentence}{} & \y{sentence}{}before \\ |
| 644 |
% & \y{sentence}{}after \\ |
| 645 |
% \x{Sentence}{Item} & \y{sentence}{begin} \\ |
| 646 |
% & \y{sentence}{end} \\ |
| 647 |
% \bottomrule |
| 648 |
% \end{tabular} |
| 649 |
% \end{center} |
| 650 |
% |
| 651 |
% \section{Loading and defining dummy texts} |
| 652 |
% \label{sec:other-texts} |
| 653 |
% |
| 654 |
% Starting with \pkg{lipsum} v2.2, a simple interface is provided to |
| 655 |
% define and load other texts for the output of \cs{lipsum} and friends. |
| 656 |
% This interface can, for example, be used to implement dummy texts in |
| 657 |
% different languages without re-coding the logic implemented by |
| 658 |
% \pkg{lipsum}. |
| 659 |
% |
| 660 |
% \begin{function}{\NewLipsumPar} |
| 661 |
% \begin{syntax} |
| 662 |
% \cs{NewLipsumPar}\Arg{paragraph} |
| 663 |
% \end{syntax} |
| 664 |
% In order to provide a new text that will be used by \pkg{lipsum}, |
| 665 |
% define the text by using a set of \cs{NewLipsumPar}\Arg{paragraph} |
| 666 |
% commands in a file with the ending |.ltd.tex| (|ltd| means |
| 667 |
% \emph{lipsum text definition}\footnotemark{}) to a location where |
| 668 |
% your \TeX{} system will find it. The \meta{paragraph}-argument is a |
| 669 |
% single paragraph of the new text. Thus, the first occurence of |
| 670 |
% \cs{NewLipsumPar} defines the first paragraph, the second occurence |
| 671 |
% the second paragraph and so on. |
| 672 |
% \end{function} |
| 673 |
% \footnotetext{To avoid name clashes with files using general languages |
| 674 |
% as names, I chose to introduce the |.ltd.tex| file ending. I did not |
| 675 |
% find a file with this ending in my |texmf|-tree, so I guess it is |
| 676 |
% safe.} |
| 677 |
% |
| 678 |
% \begin{function}{\SetLipsumLanguage} |
| 679 |
% \begin{syntax} |
| 680 |
% \cs{SetLipsumLanguage}\Arg{lang} |
| 681 |
% \end{syntax} |
| 682 |
% Additionally, tell \pkg{lipsum} the language of the dummy text using |
| 683 |
% \cs{SetLipsumLanguage}\Arg{lang} somewhere in the |.ltd.tex| file. |
| 684 |
% \end{function} |
| 685 |
% |
| 686 |
% \medskip |
| 687 |
% |
| 688 |
% To specify the new text as output for \cs{lipsum} and friends, use |
| 689 |
% \cs{setlipsum}|{|\opt{text}|=|\meta{name}|}|, where \meta{name} is the |
| 690 |
% name of the file without the ending |.ltd.tex|, as given in the table |
| 691 |
% below. When a new dummy text is loaded, the previous one is cleared, |
| 692 |
% and the language is changed as well, according to the table. |
| 693 |
% |
| 694 |
% \begin{table}[ht] |
| 695 |
% \begin{wide} |
| 696 |
% \begin{tabularx}{\textwidth}{lllX} |
| 697 |
% \toprule |
| 698 |
% File (\texttt{.ltd.tex}) & Language & Source & Description \\ |
| 699 |
% \midrule |
| 700 |
% \texttt{lipsum} & Latin |
| 701 |
% & James Wilson |
| 702 |
% & Contains the standard \emph{Lorem ipsum} dummy text, |
| 703 |
% obtained from \url{https://www.lipsum.com} (default). \\ |
| 704 |
% \texttt{cicero} & Latin |
| 705 |
% & GH user \href{https://github.com/svenper}{svenper} |
| 706 |
% & Contains the speech by Cicero which inspired the \lips{} |
| 707 |
% dummy text. \\ |
| 708 |
% \texttt{lipsum-cs} & Czech |
| 709 |
% & Ondřej Macek |
| 710 |
% & Lipsum dummy text in the Czech language, obtained from |
| 711 |
% Petr Staníček's website: |
| 712 |
% \url{https://www.wellstyled.com/tools/dummy-cz}. \\ |
| 713 |
% \bottomrule |
| 714 |
% \end{tabularx} |
| 715 |
% \end{wide} |
| 716 |
% \end{table} |
| 717 |
% |
| 718 |
% \subsection{Guidelines on providing new dummy texts} |
| 719 |
% |
| 720 |
% \cs{SetLipsumText} more or less just uses an \cs{input} or, to be more |
| 721 |
% precise, the \LaTeX3-variant \cs{file_input:n}, to load the |.ltd.tex| |
| 722 |
% file. This means, that the file is not necessarily loaded in the |
| 723 |
% preamble of the document and thus the contents of the file underlie |
| 724 |
% the respective restrictions. |
| 725 |
% |
| 726 |
% Should you want a new dummy text, create an issue in the GitHub |
| 727 |
% repository\footnote{\url{https://github.com/PhelypeOleinik/lipsum}} |
| 728 |
% with the source for the dummy text. |
| 729 |
% |
| 730 |
% Should you prefer to distribute the dummy text as a separate package, |
| 731 |
% make sure that the text follows the layout of \pkg{lipsum}'s dummy |
| 732 |
% texts, so that everything works correctly. The dummy text definition |
| 733 |
% file should contain a line with \cs{SetLipsumLanguage}, and then as |
| 734 |
% many \cs{NewLipsumPar} entries as there are paragraphs in the dummy |
| 735 |
% text. Make sure that the file has the |.ltd.tex| extension, and |
| 736 |
% everything should work smoothly. |
| 737 |
% |
| 738 |
% \end{documentation} |
| 739 |
% |
| 740 |
% \clearpage |
| 741 |
% \newgeometry{left=5cm,right=2cm} |
| 742 |
% |
| 743 |
% \begin{implementation} |
| 744 |
% |
| 745 |
% \section{\pkg{lipsum} Implementation} |
| 746 |
% |
| 747 |
% \begin{macrocode} |
| 748 |
%<*package> |
| 749 |
%<@@=lipsum> |
| 750 |
% \end{macrocode} |
| 751 |
% |
| 752 |
% \subsection{Variables} |
| 753 |
% |
| 754 |
% \begin{variable}{\g_@@_par_int} |
| 755 |
% Stores the number of paragraphs in the current text. |
| 756 |
% \begin{macrocode} |
| 757 |
\int_new:N \g_@@_par_int |
| 758 |
% \end{macrocode} |
| 759 |
% \end{variable} |
| 760 |
% |
| 761 |
% \begin{variable}{\g_@@_language_tl} |
| 762 |
% Stores the language of the dummy text for hyphenation patterns. |
| 763 |
% \begin{macrocode} |
| 764 |
\tl_new:N \g_@@_language_tl |
| 765 |
% \end{macrocode} |
| 766 |
% \end{variable} |
| 767 |
% |
| 768 |
% \begin{variable}[int]{\g_lipsum_default_range_tl} |
| 769 |
% The default range for lipsum paragraphs. |
| 770 |
% \begin{macrocode} |
| 771 |
\tl_new:N \g_lipsum_default_range_tl |
| 772 |
% \end{macrocode} |
| 773 |
% \end{variable} |
| 774 |
% |
| 775 |
% \begin{variable}{\l_@@_output_tl} |
| 776 |
% This variables is used to store the token list containing the |
| 777 |
% selected output. |
| 778 |
% \begin{macrocode} |
| 779 |
\tl_new:N \l_@@_output_tl |
| 780 |
% \end{macrocode} |
| 781 |
% \end{variable} |
| 782 |
% |
| 783 |
% \begin{variable}{\g_@@_text_str} |
| 784 |
% Holds the current text loaded for the output of \cs{lipsum} and |
| 785 |
% friends. Used to avoid loading the same text definition if it is |
| 786 |
% already used. |
| 787 |
% \begin{macrocode} |
| 788 |
\str_new:N \g_@@_text_str |
| 789 |
% \end{macrocode} |
| 790 |
% \end{variable} |
| 791 |
% |
| 792 |
% \begin{variable}{\l_@@_sep_set_str} |
| 793 |
% Holds the name of the active separator token set. By default it is |
| 794 |
% empty to use the default separator set (empty). |
| 795 |
% \begin{macrocode} |
| 796 |
\str_new:N \l_@@_sep_set_str |
| 797 |
% \end{macrocode} |
| 798 |
% \end{variable} |
| 799 |
% |
| 800 |
% \begin{variable}{\l_@@_autolang_bool} |
| 801 |
% Boolean whether to change hyphenation patterns according to the |
| 802 |
% dummy text language. |
| 803 |
% \begin{macrocode} |
| 804 |
\bool_new:N \l_@@_autolang_bool |
| 805 |
% \end{macrocode} |
| 806 |
% \end{variable} |
| 807 |
% |
| 808 |
% \begin{variable}{\q_@@_mark,\s_@@} |
| 809 |
% Quark and scan mark used throughout the package. |
| 810 |
% \begin{macrocode} |
| 811 |
\quark_new:N \q_@@_mark |
| 812 |
\scan_new:N \s_@@ |
| 813 |
% \end{macrocode} |
| 814 |
% \end{variable} |
| 815 |
% |
| 816 |
% \begin{variable}{\l_@@_tmpa_str,\l_@@_a_int,\l_@@_b_int} |
| 817 |
% Scratch variables. |
| 818 |
% \begin{macrocode} |
| 819 |
\str_new:N \l_@@_tmpa_str |
| 820 |
\int_new:N \l_@@_a_int |
| 821 |
\int_new:N \l_@@_b_int |
| 822 |
% \end{macrocode} |
| 823 |
% \end{variable} |
| 824 |
% |
| 825 |
% \begin{macro}{\@@_tmp:w} |
| 826 |
% Scratch macro. |
| 827 |
% \begin{macrocode} |
| 828 |
\cs_new_eq:NN \@@_tmp:w ? |
| 829 |
% \end{macrocode} |
| 830 |
% \end{macro} |
| 831 |
% |
| 832 |
% \begin{variable}{\l_@@_<thing>_<place>_<version>_tl} |
| 833 |
% \csname @gobble\endcsname{ |
| 834 |
% \l_@@_par_end_nostar_tl, |
| 835 |
% \l_@@_par_end_star_tl, |
| 836 |
% \l_@@_par_end__tl, |
| 837 |
% \l_@@_par_itemend_nostar_tl, |
| 838 |
% \l_@@_par_itemend_star_tl, |
| 839 |
% \l_@@_par_itemend__tl, |
| 840 |
% \l_@@_par_itemseparator_nostar_tl, |
| 841 |
% \l_@@_par_itemseparator_star_tl, |
| 842 |
% \l_@@_par_itemseparator__tl, |
| 843 |
% \l_@@_par_itemstart_nostar_tl, |
| 844 |
% \l_@@_par_itemstart_star_tl, |
| 845 |
% \l_@@_par_itemstart__tl, |
| 846 |
% \l_@@_par_start_nostar_tl, |
| 847 |
% \l_@@_par_start_star_tl, |
| 848 |
% \l_@@_par_start__tl, |
| 849 |
% \l_@@_sentence_end_nostar_tl, |
| 850 |
% \l_@@_sentence_end_star_tl, |
| 851 |
% \l_@@_sentence_end__tl, |
| 852 |
% \l_@@_sentence_itemend_nostar_tl, |
| 853 |
% \l_@@_sentence_itemend_star_tl, |
| 854 |
% \l_@@_sentence_itemend__tl, |
| 855 |
% \l_@@_sentence_itemseparator_nostar_tl, |
| 856 |
% \l_@@_sentence_itemseparator_star_tl, |
| 857 |
% \l_@@_sentence_itemseparator__tl, |
| 858 |
% \l_@@_sentence_itemstart_nostar_tl, |
| 859 |
% \l_@@_sentence_itemstart_star_tl, |
| 860 |
% \l_@@_sentence_itemstart__tl, |
| 861 |
% \l_@@_sentence_start_nostar_tl, |
| 862 |
% \l_@@_sentence_start_star_tl, |
| 863 |
% \l_@@_sentence_start__tl, |
| 864 |
% } |
| 865 |
% These variables store the separators and delimiters added around the |
| 866 |
% paragraphs and sentences, in the starred or nonstarred variants, as |
| 867 |
% well as the generic version for runtime usage. |
| 868 |
% \begin{macrocode} |
| 869 |
\clist_map_inline:nn { start, itemstart, itemseparator, itemend, end } |
| 870 |
{ |
| 871 |
\clist_map_inline:nn { par, sentence } |
| 872 |
{ |
| 873 |
\clist_map_inline:nn { { }, star, nostar } |
| 874 |
{ \tl_new:c { l_@@_##1_#1_####1_tl } } |
| 875 |
} |
| 876 |
\tl_new:c { l_@@_par_#1_parsepar_tl } |
| 877 |
} |
| 878 |
\tl_set:Nn \l_@@_par_itemseparator_parsepar_tl { ~ } |
| 879 |
% \end{macrocode} |
| 880 |
% \end{variable} |
| 881 |
% |
| 882 |
% \subsection{Developer interface} |
| 883 |
% |
| 884 |
% \begin{macro}{\@@_parse_par_range:nNN,\@@_parse_par_range:eNN} |
| 885 |
% \begin{macro}{\@@_parse_sentence_range:nNN,\@@_parse_sentence_range:eNN} |
| 886 |
% \begin{macro}{\@@_parse_range_arg:nNNn,\@@_parse_range_arg:wnNNn} |
| 887 |
% \begin{macro}{\@@_int_set:Nnn} |
| 888 |
% Parses an argument that may be a single integer or an integer range |
| 889 |
% separated by a |-|, and stores them into the integer registers |#2| |
| 890 |
% and |#3|. If a number is blank, zero is used. If only a single |
| 891 |
% number is given, |#3| is set equal to |#2|. |
| 892 |
% \begin{macrocode} |
| 893 |
\cs_new_protected:Npn \@@_parse_par_range:nNN #1 #2 #3 |
| 894 |
{ |
| 895 |
\tl_if_blank:nTF {#1} |
| 896 |
{ \exp_args:NV \@@_parse_range_arg:nNNn \g_lipsum_default_range_tl } |
| 897 |
{ \@@_parse_range_arg:nNNn {#1} } |
| 898 |
#2 #3 { \g_@@_par_int } |
| 899 |
} |
| 900 |
\cs_new_protected:Npn \@@_parse_sentence_range:nNN #1 #2 #3 |
| 901 |
{ \@@_parse_range_arg:nNNn {#1} #2 #3 { \c_max_int } } |
| 902 |
\cs_new_protected:Npn \@@_parse_range_arg:nNNn #1 |
| 903 |
{ |
| 904 |
\exp_last_unbraced:No \@@_parse_range_arg:wnNNn |
| 905 |
\tl_to_str:n { #1 - - } \s_@@ {#1} |
| 906 |
} |
| 907 |
\cs_new_protected:Npn \@@_parse_range_arg:wnNNn |
| 908 |
#1 - #2 - #3 \s_@@ #4 #5#6 #7 |
| 909 |
{ |
| 910 |
\str_if_eq:nnTF {#3} { - } |
| 911 |
{ |
| 912 |
\@@_int_set:Nnn #5 {#1} { 1 } |
| 913 |
\@@_int_set:Nnn #6 {#2} {#7} |
| 914 |
} |
| 915 |
{ |
| 916 |
\tl_if_empty:nTF {#3} |
| 917 |
{ |
| 918 |
\@@_int_set:Nnn #5 {#1} { \ERROR } |
| 919 |
\int_set_eq:NN #6 #5 |
| 920 |
} |
| 921 |
{ |
| 922 |
\msg_error:nnn { lipsum } { invalid-range } {#4} |
| 923 |
\@@_parse_range_arg:nNNn { 2 - 1 } #5 #6 {#7} |
| 924 |
} |
| 925 |
} |
| 926 |
} |
| 927 |
\cs_new_protected:Npn \@@_int_set:Nnn #1 #2 #3 |
| 928 |
{ \int_set:Nn #1 { \tl_if_blank:nT {#2} {#3} #2 } } |
| 929 |
\cs_generate_variant:Nn \@@_parse_par_range:nNN { e } |
| 930 |
\cs_generate_variant:Nn \@@_parse_sentence_range:nNN { e } |
| 931 |
% \end{macrocode} |
| 932 |
% \end{macro} |
| 933 |
% \end{macro} |
| 934 |
% \end{macro} |
| 935 |
% \end{macro} |
| 936 |
% |
| 937 |
% \begin{macro}{\@@_sep_item:nn} |
| 938 |
% A shorthand to leave an (\cs{undexpanded}) token list. |
| 939 |
% \begin{macrocode} |
| 940 |
\cs_new:Npn \@@_sep_item:nn #1 #2 |
| 941 |
{ \exp_not:v { l_@@_#1_#2_ \l_@@_sep_set_str _tl } } |
| 942 |
% \end{macrocode} |
| 943 |
% \end{macro} |
| 944 |
% |
| 945 |
% \begin{macro}[int]{\lipsum_get_range:nn} |
| 946 |
% \begin{macro}{ |
| 947 |
% \@@_build_list:nn, |
| 948 |
% \@@_build_list_aux:n, |
| 949 |
% \@@_get_paragraph:ww, |
| 950 |
% \@@_get_paragraph_end:w, |
| 951 |
% } |
| 952 |
% Expands to the paragraphs between \meta{number_1} and |
| 953 |
% \meta{number_2} with the proper delimiters added. Text is returned |
| 954 |
% in \cs{exp_not:n}, so this macro can be safely used in an \cs{edef}. |
| 955 |
% \begin{macrocode} |
| 956 |
\cs_new:Npn \lipsum_get_range:nn #1 #2 |
| 957 |
{ |
| 958 |
\@@_sep_item:nn { par } { start } |
| 959 |
\use:e |
| 960 |
{ |
| 961 |
\exp_not:N \@@_get_paragraph:ww |
| 962 |
\@@_build_list:nn {#1} {#2} |
| 963 |
\exp_not:N \q_@@_mark ; |
| 964 |
\exp_not:N \q_@@_mark ; \s_@@ |
| 965 |
} |
| 966 |
\@@_sep_item:nn { par } { end } |
| 967 |
} |
| 968 |
\cs_new:Npn \@@_build_list:nn #1 #2 |
| 969 |
{ |
| 970 |
\int_step_function:nnN |
| 971 |
{ \int_max:nn {#1} { 1 } } |
| 972 |
{ \int_min:nn {#2} { \g_@@_par_int } } |
| 973 |
\@@_build_list_aux:n |
| 974 |
} |
| 975 |
\cs_new:Npn \@@_build_list_aux:n #1 { #1 ; } |
| 976 |
\cs_new:Npn \@@_get_paragraph:ww #1 ; #2 ; |
| 977 |
{ |
| 978 |
\if_meaning:w \q_@@_mark #2 |
| 979 |
\if_meaning:w \q_@@_mark #1 |
| 980 |
\@@_get_paragraph_end:w |
| 981 |
\else: |
| 982 |
\lipsum_get_paragraph:n {#1} |
| 983 |
\fi: |
| 984 |
\else: |
| 985 |
\lipsum_get_paragraph:n {#1} |
| 986 |
\@@_sep_item:nn { par } { itemseparator } |
| 987 |
\fi: |
| 988 |
\@@_get_paragraph:ww #2 ; |
| 989 |
} |
| 990 |
\cs_new:Npn \@@_get_paragraph_end:w #1 \s_@@ { \fi: \fi: } |
| 991 |
% \end{macrocode} |
| 992 |
% \end{macro} |
| 993 |
% \end{macro} |
| 994 |
% |
| 995 |
% \begin{macro}[int]{\lipsum_get_paragraph:n} |
| 996 |
% Expands to the paragraph \meta{number} with the proper delimiters |
| 997 |
% added. Text is returned in \cs{exp_not:n}, so this macro can be |
| 998 |
% safely used in an \cs{edef}. |
| 999 |
% \begin{macrocode} |
| 1000 |
\cs_new:Npn \lipsum_get_paragraph:n #1 |
| 1001 |
{ |
| 1002 |
\@@_sep_item:nn { par } { itemstart } |
| 1003 |
\@@_unexpanded_par:n {#1} |
| 1004 |
\@@_sep_item:nn { par } { itemend } |
| 1005 |
} |
| 1006 |
% \end{macrocode} |
| 1007 |
% \end{macro} |
| 1008 |
% |
| 1009 |
% \begin{macro}{\@@_unexpanded_par:n} |
| 1010 |
% Expands to the paragraph \meta{number} wrapped in \cs{exp_not:n}. |
| 1011 |
% If \meta{number} is out of range, it expands to nothing. |
| 1012 |
% \begin{macrocode} |
| 1013 |
\cs_new:Npn \@@_unexpanded_par:n #1 |
| 1014 |
{ |
| 1015 |
\bool_lazy_and:nnT |
| 1016 |
{ \int_compare_p:nNn { 0 } < {#1} } |
| 1017 |
{ \int_compare_p:nNn {#1} < { \g_@@_par_int + 1 } } |
| 1018 |
{ \exp_not:v { g_@@_par_#1_tl } } |
| 1019 |
} |
| 1020 |
% \end{macrocode} |
| 1021 |
% \end{macro} |
| 1022 |
% |
| 1023 |
% \begin{macro}[int]{\lipsum_get_sentences:nnn,\lipsum_get_sentences:nnV} |
| 1024 |
% \begin{macro}{\@@_get_sentences:nnnw,\@@_get_sentences_end:w} |
| 1025 |
% Expands to the sentences numbered between \meta{number_1} and |
| 1026 |
% \meta{number_2}, inclusive, contained in the \meta{text}, and adding |
| 1027 |
% the proper separators. |
| 1028 |
% \begin{macrocode} |
| 1029 |
\cs_new:Npn \lipsum_get_sentences:nnn #1 #2 #3 |
| 1030 |
{ |
| 1031 |
\@@_sep_item:nn { sentence } { start } |
| 1032 |
\exp_args:Ne \use_ii_i:nn { { \int_max:nn {#1} { 1 } } } |
| 1033 |
{ \@@_get_sentences:nnnw { 1 } } {#2} |
| 1034 |
#3 ~ \q_@@_mark .~ \s_@@ |
| 1035 |
\@@_sep_item:nn { sentence } { end } |
| 1036 |
} |
| 1037 |
\cs_new:Npn \@@_get_sentences:nnnw #1 #2 #3 #4 .~ |
| 1038 |
{ |
| 1039 |
\int_compare:nNnT {#1} > {#3} { \@@_get_sentences_end:w } |
| 1040 |
\use:nn { \if_meaning:w \q_@@_mark } #4 |
| 1041 |
\exp_after:wN \@@_get_sentences_end:w |
| 1042 |
\else: |
| 1043 |
\int_compare:nNnF {#1} < {#2} |
| 1044 |
{ |
| 1045 |
\int_compare:nNnF {#1} = {#2} |
| 1046 |
{ \@@_sep_item:nn { sentence } { itemseparator } } |
| 1047 |
\@@_sep_item:nn { sentence } { itemstart } |
| 1048 |
\exp_not:n { #4 . } |
| 1049 |
\@@_sep_item:nn { sentence } { itemend } |
| 1050 |
} |
| 1051 |
\fi: |
| 1052 |
\exp_args:Nf \@@_get_sentences:nnnw { \int_eval:n { #1 + 1 } } |
| 1053 |
{#2} {#3} |
| 1054 |
} |
| 1055 |
\cs_new:Npn \@@_get_sentences_end:w #1 \s_@@ { } |
| 1056 |
\cs_generate_variant:Nn \lipsum_get_sentences:nnn { nnV } |
| 1057 |
% \end{macrocode} |
| 1058 |
% \end{macro} |
| 1059 |
% \end{macro} |
| 1060 |
% |
| 1061 |
% \subsection{User- and developer-level commands} |
| 1062 |
% |
| 1063 |
% \begin{macro}[int]{\LipsumPar} |
| 1064 |
% Macro to typeset a single paragraph of \lips\ Was not officially |
| 1065 |
% available in version prior to 2.0. |
| 1066 |
% \begin{arguments} |
| 1067 |
% \item Number of the paragraph to typeset. |
| 1068 |
% \end{arguments} |
| 1069 |
% Implemented as follows: |
| 1070 |
% \begin{macrocode} |
| 1071 |
\NewDocumentCommand \LipsumPar { m } |
| 1072 |
{ |
| 1073 |
\@@_deprecated:n { LipsumPar } |
| 1074 |
\@@_unexpanded_par:n {#1} \par |
| 1075 |
} |
| 1076 |
% \end{macrocode} |
| 1077 |
% \end{macro} |
| 1078 |
% |
| 1079 |
% \subsection{Tokens surrounding the \lips\ content} |
| 1080 |
% |
| 1081 |
% \begin{macro}{\@@_element_set:nnn} |
| 1082 |
% A general macro for setting starred/non-starred versions of several |
| 1083 |
% elements used between chunks of dummy text. Arguments are: |
| 1084 |
% \begin{arguments} |
| 1085 |
% \item Element name; |
| 1086 |
% \item Boolean true or false if the |*| variant was used; |
| 1087 |
% \item Value to set the element to. |
| 1088 |
% \end{arguments} |
| 1089 |
% \begin{macrocode} |
| 1090 |
\cs_new_protected:Npn \@@_element_set:nnn #1 #2 #3 |
| 1091 |
{ \tl_set:cn { l_@@_ #1 _ \IfBooleanF {#2} { no } star _tl } {#3} } |
| 1092 |
% \end{macrocode} |
| 1093 |
% \end{macro} |
| 1094 |
% |
| 1095 |
% \begin{macro}{\@@_deprecated:n} |
| 1096 |
% Warns about deprecated commands and destroys itself. |
| 1097 |
% \begin{macrocode} |
| 1098 |
\cs_new_protected:Npn \@@_deprecated:n #1 |
| 1099 |
{ |
| 1100 |
\msg_warning:nnn { lipsum } { cmd-deprecated } {#1} |
| 1101 |
\cs_gset_eq:NN \@@_deprecated:n \use_none:n |
| 1102 |
} |
| 1103 |
% \end{macrocode} |
| 1104 |
% \end{macro} |
| 1105 |
% |
| 1106 |
% \begin{macro}[int]{ |
| 1107 |
% \SetLipsumParListStart, |
| 1108 |
% \SetLipsumParListEnd, |
| 1109 |
% \SetLipsumParListSurrounders, |
| 1110 |
% \SetLipsumParListItemSeparator, |
| 1111 |
% \SetLipsumParListItemStart, |
| 1112 |
% \SetLipsumParListItemEnd, |
| 1113 |
% \SetLipsumParListItemSurrounders, |
| 1114 |
% \SetLipsumSentenceListStart, |
| 1115 |
% \SetLipsumSentenceListEnd, |
| 1116 |
% \SetLipsumSentenceListSurrounders, |
| 1117 |
% \SetLipsumSentenceListItemSeparator, |
| 1118 |
% \SetLipsumSentenceListItemStart, |
| 1119 |
% \SetLipsumSentenceListItemEnd, |
| 1120 |
% \SetLipsumSentenceListItemSurrounders, |
| 1121 |
% } |
| 1122 |
% A dirty loop to quickly define the old command-based user-interface. |
| 1123 |
% \begin{macrocode} |
| 1124 |
\cs_set_protected:Npn \@@_tmp:w #1 #2 #3 #4 |
| 1125 |
{ |
| 1126 |
\str_set:Nx \l_@@_tmpa_str |
| 1127 |
{ #2 \tl_if_empty:nTF {#4} {#3} { start } } |
| 1128 |
\use:e |
| 1129 |
{ |
| 1130 |
\NewDocumentCommand \exp_not:c { SetLipsum #1 List #2 #3 } |
| 1131 |
{ s +m \tl_if_empty:nF {#4} { +m } } |
| 1132 |
{ |
| 1133 |
\@@_deprecated:n { SetLipsum #1 List #2 #3 } |
| 1134 |
\@@_element_set:nnn |
| 1135 |
{ \exp_args:Ne \str_lowercase:n { #1_\l_@@_tmpa_str } } |
| 1136 |
{##1} {##2} |
| 1137 |
\tl_if_empty:nT {#4} { \use_none:nnnn } |
| 1138 |
\@@_element_set:nnn { \str_lowercase:n { #1_#2 #4 } } |
| 1139 |
{##1} {##3} |
| 1140 |
} |
| 1141 |
} |
| 1142 |
} |
| 1143 |
\clist_map_inline:nn { Par, Sentence } |
| 1144 |
{ |
| 1145 |
\clist_map_inline:nn |
| 1146 |
{ { Start } { }, { End } { }, { Surrounders } { end } } |
| 1147 |
{ \@@_tmp:w {#1} { Item } ##1 \@@_tmp:w {#1} { } ##1 } |
| 1148 |
\@@_tmp:w {#1} { Item } { Separator } { } |
| 1149 |
} |
| 1150 |
% \end{macrocode} |
| 1151 |
% \end{macro} |
| 1152 |
% |
| 1153 |
% \begin{macro}{\SetLipsumDefault} |
| 1154 |
% Command to change the default range used by \cs{lipsum} and friends. |
| 1155 |
% \begin{arguments} |
| 1156 |
% \item[\meta{range}] Range to be used as default. |
| 1157 |
% \end{arguments} |
| 1158 |
% Implemented as: |
| 1159 |
% \begin{macrocode} |
| 1160 |
\NewDocumentCommand \SetLipsumDefault { m } |
| 1161 |
{ |
| 1162 |
\@@_parse_par_range:eNN {#1} \l_@@_a_int \l_@@_b_int |
| 1163 |
\tl_gset:Nx \g_lipsum_default_range_tl |
| 1164 |
{ \int_use:N \l_@@_a_int - \int_use:N \l_@@_b_int } |
| 1165 |
} |
| 1166 |
% \end{macrocode} |
| 1167 |
% \end{macro} |
| 1168 |
% |
| 1169 |
% The following macros are considered to be user-level commands and thus |
| 1170 |
% all lower-case. |
| 1171 |
% |
| 1172 |
% \begin{macro}{\lipsum} |
| 1173 |
% \begin{arguments} |
| 1174 |
% \item Range-like string that specifies the number of the |
| 1175 |
% paragraphs taken from \lips\ If omitted, the value set by |
| 1176 |
% \cs{SetLipsumDefault} is used, which defaults to |1-7|. |
| 1177 |
% \item Sentences to be typeset from the range selected by |
| 1178 |
% \meta{paragraph range}. If sentences outside the number of |
| 1179 |
% sentences in \meta{paragraph range} are specified, only existing |
| 1180 |
% sentences are typeset. |
| 1181 |
% \end{arguments} |
| 1182 |
% The difference between \cs{lipsum} and \cs{lipsum*} is the token(s) |
| 1183 |
% that are inserted after each paragraph (only if called without the |
| 1184 |
% second optional argument). |
| 1185 |
% |
| 1186 |
% \cs{lipsum} and \cs{unpacklipsum} have the same interface and do |
| 1187 |
% almost the same thing, so both are implemented using a common macro |
| 1188 |
% \cs{@@_do:nnnn} that does the heavy-lifting, and at the end |
| 1189 |
% executes the code in |#4|. |
| 1190 |
% \begin{macrocode} |
| 1191 |
\NewDocumentCommand \lipsum { s O { \g_lipsum_default_range_tl } o } |
| 1192 |
{ |
| 1193 |
\@@_do:nnnn {#1} {#2} {#3} |
| 1194 |
{ |
| 1195 |
\@@_set_hyphens: |
| 1196 |
\tl_use:N ##1 |
| 1197 |
\@@_restore_hyphens: |
| 1198 |
} |
| 1199 |
} |
| 1200 |
% \end{macrocode} |
| 1201 |
% \end{macro} |
| 1202 |
% |
| 1203 |
% \begin{macro}{\unpacklipsum,\lipsumexp} |
| 1204 |
% This command does the same as \cs{lipsum}, but instead of |
| 1205 |
% typesetting the paragraphs or sentences, it stores the expanded |
| 1206 |
% content in the \cs{lipsumexp} token list. The tokens between items |
| 1207 |
% of the list, set, for example, by using the package option |
| 1208 |
% \opt{space} or by using the \cs{SetLipsum...List} commands, are |
| 1209 |
% |x|-expanded. |
| 1210 |
% \begin{macrocode} |
| 1211 |
\NewDocumentCommand \unpacklipsum { s O { \g_lipsum_default_range_tl } o } |
| 1212 |
{ \@@_do:nnnn {#1} {#2} {#3} { \tl_gset_eq:NN \lipsumexp ##1 } } |
| 1213 |
\cs_new_eq:NN \lipsumexp \prg_do_nothing: |
| 1214 |
% \end{macrocode} |
| 1215 |
% \end{macro} |
| 1216 |
% |
| 1217 |
% \begin{macro}{\@@_do:nnnn} |
| 1218 |
% \begin{macro}{\@@_do:N} |
| 1219 |
% This is the main macro for \cs{lipsum} and \cs{unpacklipsum}. |
| 1220 |
% It parses the paragraph range, sets the sentence/paragraph |
| 1221 |
% separators, then acts accordingly if a sentence range was provided. |
| 1222 |
% \begin{macrocode} |
| 1223 |
\cs_new_protected:Npn \@@_do:nnnn #1 #2 #3 #4 |
| 1224 |
{ |
| 1225 |
\cs_set_protected:Npn \@@_do:N ##1 {#4} |
| 1226 |
\@@_parse_par_range:eNN {#2} \l_@@_a_int \l_@@_b_int |
| 1227 |
\str_set_eq:NN \l_@@_tmpa_str \l_@@_sep_set_str |
| 1228 |
\str_set:Nx \l_@@_sep_set_str { \IfBooleanF {#1} { no } star } |
| 1229 |
\bool_lazy_or:nnTF |
| 1230 |
{ \tl_if_novalue_p:n {#3} } |
| 1231 |
{ \tl_if_blank_p:n {#3} } |
| 1232 |
{ |
| 1233 |
\tl_set:Nx \l_@@_output_tl |
| 1234 |
{ \lipsum_get_range:nn { \l_@@_a_int } { \l_@@_b_int } } |
| 1235 |
} |
| 1236 |
{ |
| 1237 |
\str_set:Nn \l_@@_sep_set_str { parsepar } |
| 1238 |
\tl_set:Nx \l_@@_output_tl |
| 1239 |
{ \lipsum_get_range:nn { \l_@@_a_int } { \l_@@_b_int } } |
| 1240 |
\str_set:Nx \l_@@_sep_set_str { \IfBooleanF {#1} { no } star } |
| 1241 |
\@@_parse_sentence_range:eNN {#3} \l_@@_a_int \l_@@_b_int |
| 1242 |
\tl_set:Nx \l_@@_output_tl |
| 1243 |
{ |
| 1244 |
\lipsum_get_sentences:nnV { \l_@@_a_int } { \l_@@_b_int } |
| 1245 |
\l_@@_output_tl |
| 1246 |
} |
| 1247 |
} |
| 1248 |
\str_set_eq:NN \l_@@_sep_set_str \l_@@_tmpa_str |
| 1249 |
\@@_do:N \l_@@_output_tl |
| 1250 |
} |
| 1251 |
\cs_new_eq:NN \@@_do:N ? |
| 1252 |
% \end{macrocode} |
| 1253 |
% \end{macro} |
| 1254 |
% \end{macro} |
| 1255 |
% |
| 1256 |
% \begin{macro}{\@@_set_hyphens:,\@@_restore_hyphens:} |
| 1257 |
% Selects the hyphenation patterns for the language of the dummy text, |
| 1258 |
% using \cs{hyphenrules} if that's defined. If \cs{hyphenrules} |
| 1259 |
% doesn't exist try setting hyphenation with \cs{@@_set_hyphens_raw:}. |
| 1260 |
% Each \cs[no-index]{@@_set_hyphens_\meta{method}:} function |
| 1261 |
% appropriately redefines \cs{@@_restore_hypehens:} to reset the |
| 1262 |
% hyphenation patterns. |
| 1263 |
% \begin{macrocode} |
| 1264 |
\cs_new_protected:Npn \@@_set_hyphens: |
| 1265 |
{ |
| 1266 |
\bool_if:NTF \l_@@_autolang_bool |
| 1267 |
{ \use:n } { \use_none:n } |
| 1268 |
{ |
| 1269 |
\cs_if_exist:NTF \hyphenrules |
| 1270 |
{ |
| 1271 |
\cs_if_exist:cTF { [email protected] } |
| 1272 |
{ \@@_set_hyphens_polyglossia: } |
| 1273 |
{ \@@_set_hyphens_babel: } |
| 1274 |
} |
| 1275 |
{ \@@_set_hyphens_raw: } |
| 1276 |
} |
| 1277 |
} |
| 1278 |
\cs_new_protected:Npn \@@_restore_hyphens: |
| 1279 |
{ \prg_do_nothing: } |
| 1280 |
% \end{macrocode} |
| 1281 |
% \end{macro} |
| 1282 |
% |
| 1283 |
% \begin{macro}{\@@_set_hyphens_babel:} |
| 1284 |
% \pkg{babel} makes things pretty simple. We just check if |
| 1285 |
% \cs[no-index]{l@\meta{lang}} is defined, and if so, use |
| 1286 |
% \cs{hyphenrules} to set it, and once more to reset in |
| 1287 |
% \cs{@@_restore_hyphens:}. \cs{hyphenrules} is actually an |
| 1288 |
% environment, but in \pkg{babel} its \cs[no-index]{end} part does |
| 1289 |
% nothing, and its effect can be undone by just using another |
| 1290 |
% \cs{hyphenrules} on top of it. |
| 1291 |
% |
| 1292 |
% If the language is not defined, the language either doesn't exist at |
| 1293 |
% all, or we are using Lua\TeX. Both cases are handled by |
| 1294 |
% \cs{@@_lang_not_available:}. |
| 1295 |
% \begin{macrocode} |
| 1296 |
\cs_new_protected:Npn \@@_set_hyphens_babel: |
| 1297 |
{ |
| 1298 |
\cs_if_exist:cTF { l@ \g_@@_language_tl } |
| 1299 |
{ |
| 1300 |
\exp_args:NV \hyphenrules \g_@@_language_tl |
| 1301 |
\cs_set_protected:Npx \@@_restore_hyphens: |
| 1302 |
{ \exp_not:N \hyphenrules { \languagename } } |
| 1303 |
} |
| 1304 |
{ \@@_lang_not_available: } |
| 1305 |
} |
| 1306 |
% \end{macrocode} |
| 1307 |
% \end{macro} |
| 1308 |
% |
| 1309 |
% \begin{macro}{\@@_set_hyphens_polyglossia:} |
| 1310 |
% \pkg{polyglossia} less friendly. We also check if the language is |
| 1311 |
% loaded (looking at \cs[no-index]{\meta{lang}@loaded}), and if it |
| 1312 |
% is, load it with the \env{hyphenrules} environment. Here we can't |
| 1313 |
% use the command form, as the \cs[no-index]{end} part is not a no-op. |
| 1314 |
% This also means that an extra group is added around the dummy text, |
| 1315 |
% which causes issue \ghissue{1} when used with \pkg{wrapfig}, for |
| 1316 |
% example. But not too much we can do about that for now. |
| 1317 |
% |
| 1318 |
% In case the language is not loaded, fall back to |
| 1319 |
% \cs{@@_set_hyphens_raw:} for a final attempt before giving up. |
| 1320 |
% \begin{macrocode} |
| 1321 |
\cs_new_protected:Npn \@@_set_hyphens_polyglossia: |
| 1322 |
{ |
| 1323 |
\cs_if_exist:cTF { \g_@@_language_tl @loaded } |
| 1324 |
{ |
| 1325 |
\exp_args:NnV \begin{hyphenrules} \g_@@_language_tl |
| 1326 |
\cs_set_protected:Npn \@@_restore_hyphens: |
| 1327 |
{ \end{hyphenrules} } |
| 1328 |
} |
| 1329 |
{ \@@_set_hyphens_raw: } |
| 1330 |
} |
| 1331 |
% \end{macrocode} |
| 1332 |
% \end{macro} |
| 1333 |
% |
| 1334 |
% \begin{macro}{\@@_set_hyphens_raw:} |
| 1335 |
% If nothing else is available, try setting the language using |
| 1336 |
% \cs{language}\meta{number}. This is always available, |
| 1337 |
% except with Lua\TeX, which loads languages on-the-fly. |
| 1338 |
% \begin{macrocode} |
| 1339 |
\cs_new_protected:Npn \@@_set_hyphens_raw: |
| 1340 |
{ |
| 1341 |
\cs_if_exist:cTF { l@ \g_@@_language_tl } |
| 1342 |
{ |
| 1343 |
\use:x |
| 1344 |
{ |
| 1345 |
\language \use:c { l@ \g_@@_language_tl } |
| 1346 |
\cs_set_protected:Npn \@@_restore_hyphens: |
| 1347 |
{ \language \int_eval:n { \language } \scan_stop: } |
| 1348 |
} |
| 1349 |
} |
| 1350 |
{ \@@_lang_not_available: } |
| 1351 |
} |
| 1352 |
% \end{macrocode} |
| 1353 |
% \end{macro} |
| 1354 |
% |
| 1355 |
% \begin{macro}{\@@_lang_not_available:} |
| 1356 |
% If the requested language is for some reason unavailable, warn the |
| 1357 |
% user, then fall back to the current language. |
| 1358 |
% \begin{macrocode} |
| 1359 |
\cs_new_protected:Npn \@@_lang_not_available: |
| 1360 |
{ |
| 1361 |
\msg_warning:nnx { lipsum } { missing-language } |
| 1362 |
{ \g_@@_language_tl } |
| 1363 |
\tl_gset_eq:NN \g_@@_language_tl \languagename |
| 1364 |
} |
| 1365 |
% \end{macrocode} |
| 1366 |
% \end{macro} |
| 1367 |
% |
| 1368 |
% \begin{macro}{\NewLipsumPar} |
| 1369 |
% Developer-Level macro to add a paragraph to the dummy text used by |
| 1370 |
% \cs{lipsum} and related commands. To specify a new dummy text, see |
| 1371 |
% section~\ref{sec:other-texts}. |
| 1372 |
% \begin{macrocode} |
| 1373 |
\cs_new_protected:Npn \NewLipsumPar #1 |
| 1374 |
{ |
| 1375 |
\int_gincr:N \g_@@_par_int |
| 1376 |
\tl_gclear_new:c { g_@@_par_ \int_use:N \g_@@_par_int _tl } |
| 1377 |
\tl_gset:cn { g_@@_par_ \int_use:N \g_@@_par_int _tl } {#1} |
| 1378 |
} |
| 1379 |
% \end{macrocode} |
| 1380 |
% \end{macro} |
| 1381 |
% |
| 1382 |
% \begin{macro}{\SetLipsumText} |
| 1383 |
% Used to select and load the text output by \cs{lipsum} and friends. |
| 1384 |
% See the section on loading and defining new outputs for \cs{lipsum} |
| 1385 |
% (section~\ref{sec:other-texts}). It first checks whether the |
| 1386 |
% requested text is already loaded, and if not, it loads the |
| 1387 |
% corresponding lipsum text definition file, and clears remaining |
| 1388 |
% paragraphs from the previous text, in case their lengths differ. |
| 1389 |
% \begin{macrocode} |
| 1390 |
\NewDocumentCommand \SetLipsumText { m } |
| 1391 |
{ |
| 1392 |
\str_if_eq:VnF \g_@@_text_str {#1} |
| 1393 |
{ |
| 1394 |
\tl_gset:Nn \g_@@_language_tl { english } |
| 1395 |
\int_gzero:N \g_@@_par_int |
| 1396 |
\file_input:n { #1.ltd } |
| 1397 |
\str_gset:Nn \g_@@_text_str {#1} |
| 1398 |
} |
| 1399 |
} |
| 1400 |
% \end{macrocode} |
| 1401 |
% \end{macro} |
| 1402 |
% |
| 1403 |
% \begin{macro}{\SetLipsumLanguage} |
| 1404 |
% This macro sets the language for hyphenation patterns of the dummy |
| 1405 |
% text. When a new lipsum text is read, this is reset. |
| 1406 |
% \begin{macrocode} |
| 1407 |
\NewDocumentCommand \SetLipsumLanguage { m } |
| 1408 |
{ \tl_gset:Nn \g_@@_language_tl {#1} } |
| 1409 |
% \end{macrocode} |
| 1410 |
% \end{macro} |
| 1411 |
% |
| 1412 |
% \subsection{Package options and defaults} |
| 1413 |
% |
| 1414 |
% \begin{macro}[int]{ |
| 1415 |
% \LipsumRestoreParList, |
| 1416 |
% \LipsumRestoreSentenceList, |
| 1417 |
% \LipsumRestoreAll, |
| 1418 |
% } |
| 1419 |
% \begin{macro}{\@@_delim_restore:nnn} |
| 1420 |
% \begin{macro}{\@@_restore_par_list:,\@@_restore_sentence_list:} |
| 1421 |
% These are some auxiliaries for the package options and for setting |
| 1422 |
% up the default behaviour. |
| 1423 |
% \begin{macrocode} |
| 1424 |
\cs_new_protected:Npn \@@_delim_restore:nnn #1 #2 #3 |
| 1425 |
{ |
| 1426 |
\keys_set:nn { lipsum } |
| 1427 |
{ |
| 1428 |
#1-before = , #1-begin = , #1-end = , #1-after = , |
| 1429 |
#1-before* = , #1-begin* = , #1-end* = , #1-after* = , |
| 1430 |
#1-sep = {#2}, #1-sep* = {#3} |
| 1431 |
} |
| 1432 |
} |
| 1433 |
\cs_new_protected:Nn \@@_restore_sentence_list: |
| 1434 |
{ \@@_delim_restore:nnn { sentence } { ~ } { ~ } } |
| 1435 |
\cs_new_eq:NN \@@_restore_par_list: ? |
| 1436 |
\cs_new_protected:Npn \LipsumRestoreParList |
| 1437 |
{ |
| 1438 |
\@@_deprecated:n { LipsumRestoreParList } |
| 1439 |
\@@_restore_par_list: |
| 1440 |
} |
| 1441 |
\cs_new_protected:Npn \LipsumRestoreSentenceList |
| 1442 |
{ |
| 1443 |
\@@_deprecated:n { LipsumRestoreSentenceList } |
| 1444 |
\@@_restore_sentence_list: |
| 1445 |
} |
| 1446 |
\cs_new_protected:Npn \LipsumRestoreAll |
| 1447 |
{ |
| 1448 |
\@@_deprecated:n { LipsumRestoreAll } |
| 1449 |
\@@_restore_par_list: \@@_restore_sentence_list: |
| 1450 |
} |
| 1451 |
% \end{macrocode} |
| 1452 |
% \end{macro} |
| 1453 |
% \end{macro} |
| 1454 |
% \end{macro} |
| 1455 |
% |
| 1456 |
% \begin{macro}{\setlipsum} |
| 1457 |
% Here are the options available at load-time and to \cs{setlipsum}. |
| 1458 |
% \begin{macrocode} |
| 1459 |
\NewDocumentCommand \setlipsum { +m } |
| 1460 |
{ \keys_set:nn { lipsum } {#1} } |
| 1461 |
\keys_define:nn { lipsum } |
| 1462 |
{ |
| 1463 |
% \end{macrocode} |
| 1464 |
% \opt{nopar} is implemented as a choice key instead of a boolean so |
| 1465 |
% we can update the separators using \cs{@@_delim_restore:nnn}. |
| 1466 |
% It's initially false, and the default is |true| so that |
| 1467 |
% |\usepackage[nopar]{lipsum}| works as it always did. |
| 1468 |
% \begin{macrocode} |
| 1469 |
nopar .choice: , |
| 1470 |
nopar / true .code:n = |
| 1471 |
{ |
| 1472 |
\cs_gset_protected:Npn \@@_restore_par_list: |
| 1473 |
{ \@@_delim_restore:nnn { par } { ~ } { \par } } |
| 1474 |
} , |
| 1475 |
nopar / false .code:n = |
| 1476 |
{ |
| 1477 |
\cs_gset_protected:Nn \@@_restore_par_list: |
| 1478 |
{ \@@_delim_restore:nnn { par } { \par } { ~ } } |
| 1479 |
} , |
| 1480 |
nopar .initial:n = false , |
| 1481 |
nopar .default:n = true , |
| 1482 |
% \end{macrocode} |
| 1483 |
% \opt{auto-lang} sets \cs{l_@@_autolang_bool}. It is initially |
| 1484 |
% |true|, changing the default behaviour from previous versions. |
| 1485 |
% \begin{macrocode} |
| 1486 |
auto-lang .bool_set:N = \l_@@_autolang_bool , |
| 1487 |
auto-lang .initial:n = true , |
| 1488 |
auto-lang .default:n = true , |
| 1489 |
% \end{macrocode} |
| 1490 |
% \opt{text} just does \cs{SetLipsumText}. The |initial| value is not |
| 1491 |
% set here because this chunk of code is executed in \pkg{expl3} |
| 1492 |
% syntax, then thetextloadswithoutspaces, so |\setlipsum{text=lipsum}| |
| 1493 |
% is used later. |
| 1494 |
% \begin{macrocode} |
| 1495 |
text .code:n = \SetLipsumText{#1} , |
| 1496 |
text .value_required:n = true , |
| 1497 |
% \end{macrocode} |
| 1498 |
% \opt{language} sets the language to be used when typesetting. |
| 1499 |
% \begin{macrocode} |
| 1500 |
language .tl_gset:N = \g_@@_language_tl , |
| 1501 |
language .value_required:n = true , |
| 1502 |
% \end{macrocode} |
| 1503 |
% \opt{default-range} does \cs{SetLipsumDefault}, initially |1-7|, as |
| 1504 |
% documented. It's default is also |1-7| so that the key has two |
| 1505 |
% meanings: \cs{setlipsum}|{default-range=|\meta{range}|}| sets the |
| 1506 |
% range to the given value, while \cs{setlipsum}|{default-range}| sets |
| 1507 |
% the range to the ``default default range''. Pretty neat :) |
| 1508 |
% \begin{macrocode} |
| 1509 |
default-range .code:n = \SetLipsumDefault{#1} , |
| 1510 |
default-range .initial:n = 1-7 , |
| 1511 |
default-range .default:n = 1-7 , |
| 1512 |
} |
| 1513 |
% \end{macrocode} |
| 1514 |
% This chunk defines the keys \meta{thing}-\meta{place}[*], where |
| 1515 |
% \meta{thing} is |par| or |sentence|, \meta{place} is |before|, |
| 1516 |
% |begin|, |sep|, |end|, and |after|, which totals~10 keys, and |
| 1517 |
% another~10 with the |*| in the name. Each sets a token list called |
| 1518 |
% \cs[no-index]{l_@@_\meta{thing}_\meta{place}_[no]star_tl}. |
| 1519 |
% \begin{macrocode} |
| 1520 |
\cs_set_protected:Npn \@@_tmp:w #1 #2 #3 |
| 1521 |
{ |
| 1522 |
\keys_define:nn { lipsum } |
| 1523 |
{ |
| 1524 |
#1-before #2 .tl_set:c = l_@@_#1_start _#3star_tl , |
| 1525 |
#1-begin #2 .tl_set:c = l_@@_#1_itemstart _#3star_tl , |
| 1526 |
#1-sep #2 .tl_set:c = l_@@_#1_itemseparator _#3star_tl , |
| 1527 |
#1-end #2 .tl_set:c = l_@@_#1_itemend _#3star_tl , |
| 1528 |
#1-after #2 .tl_set:c = l_@@_#1_end _#3star_tl , |
| 1529 |
} |
| 1530 |
} |
| 1531 |
\@@_tmp:w { par } { } { no } \@@_tmp:w { sentence } { } { no } |
| 1532 |
\@@_tmp:w { par } * { } \@@_tmp:w { sentence } * { } |
| 1533 |
% \end{macrocode} |
| 1534 |
% \end{macro} |
| 1535 |
% |
| 1536 |
% Now turn \cs{ExplSyntaxOff} for a while, and load the default \lips{} |
| 1537 |
% text, then process the package options, and finally turn |
| 1538 |
% \cs{ExplSyntaxOn} again. Finally, call \cs{@@_restore_par_list:} and |
| 1539 |
% \cs{@@_restore_sentence_list:} to set the defaults |
| 1540 |
% (\cs{@@_restore_par_list:} may have been redefined by \opt{nopar}). |
| 1541 |
% \begin{macrocode} |
| 1542 |
\ExplSyntaxOff |
| 1543 |
\setlipsum{text=lipsum} |
| 1544 |
\ProcessKeysOptions{lipsum} |
| 1545 |
\ExplSyntaxOn |
| 1546 |
\@@_restore_par_list: |
| 1547 |
\@@_restore_sentence_list: |
| 1548 |
% \end{macrocode} |
| 1549 |
% |
| 1550 |
% \subsection{Messages} |
| 1551 |
% |
| 1552 |
% Now define the messages used throughout the package. |
| 1553 |
% \begin{macrocode} |
| 1554 |
\msg_new:nnn { lipsum } { invalid-range } |
| 1555 |
{ Invalid~number~or~range~'#1'. } |
| 1556 |
\msg_new:nnn { lipsum } { cmd-deprecated } |
| 1557 |
{ |
| 1558 |
Command~'\iow_char:N\\#1'~deprecated. \\ |
| 1559 |
See~the~lipsum~documentation~for~help. |
| 1560 |
} |
| 1561 |
\msg_new:nnn { lipsum } { missing-language } |
| 1562 |
{ |
| 1563 |
Unknown~language~'#1'.~Hyphenation~patterns~for~ |
| 1564 |
'\languagename'~will~be~used~instead. |
| 1565 |
\sys_if_engine_luatex:T |
| 1566 |
{ |
| 1567 |
\\ \\ |
| 1568 |
\cs_if_exist:cTF { [email protected] } |
| 1569 |
{ |
| 1570 |
With~polyglossia,~you~have~to~explicitly~load~languages~ |
| 1571 |
with~\iow_char:N\\setotherlanguage{#1}~or~similar. |
| 1572 |
} |
| 1573 |
{ |
| 1574 |
With~LuaTeX,~lipsum~requires~babel~to~get~proper~ |
| 1575 |
hyphenation~(you~can~use~ |
| 1576 |
\iow_char:N\\usepackage[base]{babel}). |
| 1577 |
} |
| 1578 |
} |
| 1579 |
} |
| 1580 |
% \end{macrocode} |
| 1581 |
% |
| 1582 |
% \begin{macrocode} |
| 1583 |
%</package> |
| 1584 |
% \end{macrocode} |
| 1585 |
% |
| 1586 |
% \end{implementation} |
| 1587 |
% |
| 1588 |
% \endinput |
| 1589 |
% Local Variables: |
| 1590 |
% mode: doctex |
| 1591 |
% TeX-master: t |
| 1592 |
% End: |