\lipsum 默认在每个应用程序中产生不同的段落

\lipsum 默认在每个应用程序中产生不同的段落

我为学生编写了一个模板 latex 文件。在这个文件中,我使用\lipsum命令作为节的占位符。下面您将看到一个不是绝对最小的示例,但模板的一个相当精简的版本。请求是一些魔法,使每个\lipsum生成不同的段落

\title{My First Article} 
\author{First Last\\
  \url{mailto:[email protected]}\\
    Department of Computer Science\\
    Technion---Israel Institute of Technology\\
}


% Only one of the following lines should be uncommented:
% \documentclass[10pt,twocolumn]{article} % Uncomment this line for 10pt/double column
  \documentclass{article}                 % Uncomment this line for 12t/single column

\usepackage{lipsum}
\setlipsumdefault{1}

\usepackage[colorlinks=true,final,allcolors=blue,breaklinks,draft=false]{hyperref}

\begin{document}
\maketitle

\begin{flushright}
  \begin{minipage}{2.5in}
    \normalsize \rmfamily\scshape\bfseries
    \color{red}{%
      Thou Mortal, Be Warned. \newline
      Thou Shallt Not Remove \newline
      This Commandment \newline
      While There Are Signs of Haste \newline
      in This Document!!!!\newline
    }
  \end{minipage}
\end{flushright}

\begin{abstract}
  \lipsum
\end{abstract}

\section{Introduction}
Something short: \lipsum
\subsection{Background}
\lipsum

\subsection{Motivation}
\lipsum

\subsection{Contribution}
\lipsum

\paragraph{Outline} \lipsum

\end{document}

答案1

使用计数器并生成\lipsum[<value>-<value+y>],其中y比您想要的段落数少一。

\documentclass{article}
\usepackage{lipsum}

\newcounter{yolipsum}
\newcommand{\yolipsum}{%
  \stepcounter{yolipsum}%
  \lipsum[\value{yolipsum}-\numexpr\value{yolipsum}+\yomany\relax]%
  \addtocounter{yolipsum}{\yomany}%
}

% change to the number of paragraphs you want;
% the number of generated paragraphs is \yomany+1
\newcommand{\yomany}{2} % can be 0

\begin{document}

\section{Three pars}

\yolipsum

\section{Three pars}

\yolipsum

\section{Three pars}

\yolipsum

\end{document}

相关内容