lipsum
,blindtext
并且kantlipsum
所有方法似乎都默认生成段落,而我希望它们生成单个句子。从文档中看,似乎应该可以选择random
生成blindtext
单个句子,但我无法让它工作:
\documentclass{article}
\usepackage[random]{blindtext}
\setcounter{blindtext}{1}
\begin{document}
\blindtext
\end{document}
我明白了
软件包 blindtext 警告:未为英语定义选项 random
现在,文档确实random
这么说:
如果语言不支持此选项,则使用默认文本。
但有点令人惊讶的是它不支持英语......我做错了什么吗?
答案1
您可以使用以下变体,lipsum.sty
它将生成句子而不是段落;将以下文件保存为sentlipsum.sty
当前工作目录或本地树中:
%%
%% This is file `sentlipsum.sty',
%% A small variation of 'lipsum.sty' originally written by Patrick Happel
%%
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{sentlipsum}[2012/12/16 v1.0 150 sentences of Lorem Ipsum dummy text]
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%% Digits \0\1\2\3\4\5\6\7\8\9
%% Exclamation \! Double quote \" Hash (number) \#
%% Dollar \$ Percent \% Ampersand \&
%% Acute accent \' Left paren \( Right paren \)
%% Asterisk \* Plus \+ Comma \,
%% Minus \- Point \. Solidus \/
%% Colon \: Semicolon \; Less than \<
%% Equals \= Greater than \> Question mark \?
%% Commercial at \@ Left bracket \[ Backslash \\
%% Right bracket \] Circumflex \^ Underscore \_
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
%%
\newcounter{sentlips@count}
\setcounter{sentlips@count}{0}
\ProcessOptions
\newcommand\sentlips@default{1-7}
\newcommand\setsentlipsumdefault[1]{%
\renewcommand{\sentlips@default}{#1}}
\newcommand\sentlips@dosentlipsum{%
\ifnum\value{sentlips@count}<\sentlips@max\relax%
\addtocounter{sentlips@count}{1}%
\csname sentlipsum@\roman{sentlips@count}\endcsname\ %
\sentlips@dosentlipsum%
\fi%
}
\newcommand\sentlipsum{\@sentlipsum}
\newcommand\@sentlipsum[1][\sentlips@default]{%
\expandafter\sentlips@minmax\expandafter{#1}%
\setcounter{sentlips@count}{\sentlips@min}%
\addtocounter{sentlips@count}{-1}%
\sentlips@dosentlipsum%
}
\def\sentlips@get#1-#2;{\def\sentlips@min{#1}\def\sentlips@max{#2}}
\def\sentlips@stripmax#1-{\edef\sentlips@max{#1}}
\def\sentlips@minmax#1{%
\sentlips@get#1-\relax;%
\edef\sentlips@tmpa{\sentlips@max}%
\edef\sentlips@relax{\relax}%
\ifx\sentlips@tmpa\sentlips@relax\edef\sentlips@max{\sentlips@min}%
\else\expandafter\sentlips@stripmax\sentlips@max\fi%
}
\newcommand\sentlipsum@i{Lorem ipsum dolor sit amet, consectetuer
adipiscing elit.}
\newcommand\sentlipsum@ii{Nam dui ligula, fringilla a, euismod sodales,
sollicitudin vel, wisi.}
\newcommand\sentlipsum@iii{Nulla malesuada porttitor diam.}
\newcommand\sentlipsum@iv{Quisque ullamcorper placerat ipsum.}
\newcommand\sentlipsum@v{Fusce mauris et vestibulum luctus nibh at lectus.}
\newcommand\sentlipsum@vi{Ut lorem lorem, interdum
eu, tincidunt sit amet, laoreet vitae, arcu.}
\newcommand\sentlipsum@vii{In hac habitasse platea
dictumst.}
\newcommand\sentlipsum@viii{Pellentesque habitant morbi tristique senectus
et netus et malesuada fames ac turpis egestas.}
\newcommand\sentlipsum@ix{Morbi luctus, wisi viverra faucibus pretium,
nibh est placerat odio, nec commodo wisi enim eget quam.}
\newcommand\sentlipsum@x{Suspendisse vitae elit.}
\newcommand\sentlipsum@xi{Cum sociis natoque penatibus et
magnis dis parturient montes, nascetur ridiculus mus.}
\newcommand\sentlipsum@xii{Fusce facilisis lacinia dui.}
\newcommand\sentlipsum@xiii{Nullam elementum, magna in cursus sodales, augue est scelerisque sapien, venenatis congue nulla arcu et pede.}
\newcommand\sentlipsum@xiv{Etiam ac leo a risus tristique nonummy.}
\newcommand\sentlipsum@xv{Praesent eros nulla, congue
vitae, euismod ut, commodo a, wisi.}
\newcommand\sentlipsum@xvi{Nulla mattis luctus nulla.}
\newcommand\sentlipsum@xvii{Curabitur tellus magna, porttitor a, commodo
a, commodo in, tortor.}
\newcommand\sentlipsum@xviii{Donec et nisl at wisi luctus bibendum. Nam
interdum tellus ac libero.}
\newcommand\sentlipsum@xix{Nulla non mauris vitae wisi posuere convallis.}
\newcommand\sentlipsum@xx{Nullam urna nulla, ullamcorper
in, interdum sit amet, gravida ut, risus.}
\newcommand\sentlipsum@xxi{Etiam pede massa, dapibus vitae, rhoncus in,
placerat posuere, odio.}
\newcommand\sentlipsum@xxii{Etiam suscipit aliquam arcu.}
\newcommand\sentlipsum@xxiii{Donec et nisl id sapien blandit mattis.}
\newcommand\sentlipsum@xxiv{Vestibulum pharetra nulla
at lorem.}
\newcommand\sentlipsum@xxv{Vivamus eu tellus sed tellus consequat
suscipit.}
\newcommand\sentlipsum@xxvi{Duis aliquet dui in est.}
\newcommand\sentlipsum@xxvii{Donec vel nibh ut felis consectetuer laoreet.}
\newcommand\sentlipsum@xxviii{Donec molestie, magna ut luctus ultrices,
tellus arcu nonummy velit, sit amet pulvinar elit justo et mauris.}
\newcommand\sentlipsum@xxix{Cras dapibus, augue quis scelerisque
ultricies, felis dolor placerat sem, id porta velit odio eu elit.}
\newcommand\sentlipsum@xxx{Sed mattis, erat sit amet gravida malesuada,
elit augue egestas diam, tempus scelerisque nunc nisl vitae libero.}
\newcommand\sentlipsum@xxxi{Sed consequat tellus et tortor.}
\newcommand\sentlipsum@xxxii{Duis malesuada interdum
arcu.}
\newcommand\sentlipsum@xxxiii{Sed eleifend, eros sit amet faucibus
elementum, urna sapien consectetuer mauris, quis egestas leo justo
non risus.}
\newcommand\sentlipsum@xxxiv{Nullam eleifend justo in nisl.}
\newcommand\sentlipsum@xxxv{Class aptent taciti sociosqu ad litora
torquent per conubia nostra, per inceptos hymenaeos.}
\newcommand\sentlipsum@xxxvi{Nulla malesuada risus ut urna.}
\newcommand\sentlipsum@xxxvii{Donec tempus neque vitae est. Aenean egestas
odio sed risus ullamcorper ullamcorper.}
\newcommand\sentlipsum@xxxviii{Fusce suscipit cursus sem.}
\newcommand\sentlipsum@xxxix{Praesent sed neque id pede mollis rutrum.}
\newcommand\sentlipsum@xl{Sed gravida lectus ut purus.}
\newcommand\lipsum@xli{Vivamus non justo in dui mattis posuere.}
\newcommand\lipsum@xlii{In suscipit mauris a
dolor pellentesque consectetuer.}
\newcommand\lipsum@xliii{Maecenas accumsan dapibus sapien.}
\newcommand\lipsum@xliv{Phasellus fringilla, metus id feugiat
consectetuer, lacus wisi ultrices tellus, quis lobortis nibh lorem
quis tortor.}
\newcommand\lipsum@xlv{Cras egestas ipsum a nisl.}
\newcommand\lipsum@xlvi{Vivamus fringilla, enim et commodo
malesuada, tortor metus elementum ligula, nec aliquet est sapien ut
lectus.}
\newcommand\lipsum@xlvii{Vivamus ante ante, mattis laoreet, posuere eget, congue vel, nunc.}
\newcommand\lipsum@xlviii{Quisque posuere metus viverra pede.}
\newcommand\lipsum@xlix{Vivamus augue purus, laoreet in, scelerisque vel,
commodo id, wisi.}
\newcommand\lipsum@l{Quisque facilisis auctor sapien.}
\newcommand\lipsum@li{Aliquam volutpat auctor lorem et cras placerat est vitae lectus.}
\newcommand\lipsum@lii{Suspendisse porta fermentum mauris.}
\newcommand\lipsum@liii{Phasellus placerat vulputate quam.}
\newcommand\lipsum@liv{Maecenas ultrices mi
sed diam.}
\newcommand\lipsum@lv{Nullam elit sapien, eleifend eu,
commodo nec, semper sit amet, elit.}
\newcommand\lipsum@lvi{Morbi tincidunt posuere arcu.}
\newcommand\lipsum@lvii{Nunc interdum elementum urna.}
\newcommand\lipsum@lviii{Nulla sit amet nisl at
sapien egestas pretium.}
\newcommand\lipsum@lix{Nunc tincidunt, risus quis bibendum
facilisis, lorem purus rutrum neque, nec porta tortor urna quis
orci.}
\newcommand\lipsum@lx{Vestibulum in leo eu erat tristique mattis.}
\endinput
%%
%% End of file `sentlipsum.sty'.
主命令是\sentlipsum
,其行为方式类似于\lipsum
(来自lipsum
包):\sentlipsum
产生七个句子;\sentlipsum[<number>]
,其中<number>
是 1 到 60 之间的整数,产生与 对应的编号的句子<number>
,并\sentlipsum[<number1>-<number2>]
产生<number2>-<number1>+1
从与 关联的句子开始到<number1>
与 关联的句子结束的句子<number2>
(同样,两个数字都必须是 1 到 60 之间的整数)。
\documentclass[parskip=full+]{scrartcl}
\usepackage{sentlipsum}
\begin{document}
\sentlipsum
\sentlipsum[1]
\sentlipsum[23-26]
\end{document}
我仅使用了scratcl
选项parfill=full*
来快速获得段落之间的视觉分隔作为示例。
答案2
这是一个基于的句子生成器kantlipsum
:
\documentclass{article}
\usepackage{kantlipsum}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\kantsentences}{ O{1} m }
{
\kgl_sentences:nn { #1 } { #2 }
}
\cs_new_protected:Npn \kgl_sentences:nn #1 #2
{
\group_begin:
\cs_set_eq:NN \kgl_number:n \use_none:n
\cs_set_eq:NN \kgl_par: \prg_do_nothing:
\tl_gclear:N \g_tmpa_tl
\prg_replicate:nn { #2/5 + 1 }
{
\tl_set:Nx \l_tmpa_tl { \seq_item:Nn \g_kgl_pars_seq {#1} }
\tl_gput_right:Nx \g_tmpa_tl { \tl_use:N \l_tmpa_tl }
\tl_gput_right:Nn \g_tmpa_tl { ~ }
}
\group_end:
\seq_set_split:NnV \l_tmpa_seq {.} \g_tmpa_tl
\int_step_inline:nnnn { 1 } { 1 } { #2 }
{
\seq_item:Nn \l_tmpa_seq { ##1 } .\par
}
}
\ExplSyntaxOff
\begin{document}
\section{Four sentences}
\kantsentences{4}
\section{Nine sentences}
\kantsentences[10]{9}
\end{document}
我利用了这样一个事实:康德式段落通常由七个句子组成。因此,我将请求的数量除以五并加一,然后将这个数量的康德式段落收集到一个唯一的标记列表中,从中提取请求的句子数量。
可选参数\kantsentences
是初始康德段落(默认为 1)。