如何迭代/循环 minipage 即执行具有相同内容的相同 minpage?

如何迭代/循环 minipage 即执行具有相同内容的相同 minpage?

我有以下代码,我一次又一次地写入相同的小页面。我想用相同的输出写入一次这个小页面。

\documentclass{article}
\usepackage{booktabs}
\usepackage[a4paper,left=0cm,top=0.2cm,bottom=0cm,right=0cm]{geometry}
\usepackage{polyglossia}
\setmainlanguage[numerals=Devanagari]{bengali}
\setmainlanguage{bengali}
\setotherlanguage{english}
%\newfontfamily\englishfont[Scale=MatchLowercase]{Linux Biolinum O}
\newfontfamily\bengalifont[Script=Bengali]{Akaash}
\usepackage{pgffor}
\newcommand{\ListItem}[1]{\underline{\makebox[5cm][l]{#1}}}
\begin{document}
\begin{minipage}{0.33\textwidth}
\foreach \x in {চাল,ডাল,লবণ,তেল,মরিচ,পেঁয়াজ,রসুন,আদা,মুরগী,মশলা}
{
\ListItem{\x}\par\bigskip}
\end{minipage}
\begin{minipage}{0.33\textwidth}
\foreach \x in {চাল,ডাল,লবণ,তেল,মরিচ,পেঁয়াজ,রসুন,আদা,মুরগী,মশলা}
{
\ListItem{\x}\par\bigskip}
\end{minipage}
\begin{minipage}{0.33\textwidth}
\foreach \x in {চাল,ডাল,লবণ,তেল,মরিচ,পেঁয়াজ,রসুন,আদা,মুরগী,মশলা}
{
\ListItem{\x}\par\bigskip}
\end{minipage}
\\

\vspace{2cm}
\begin{minipage}{0.33\textwidth}
\foreach \x in {চাল,ডাল,লবণ,তেল,মরিচ,পেঁয়াজ,রসুন,আদা,মুরগী,মশলা}
{
\ListItem{\x}\par\bigskip}
\end{minipage}
\begin{minipage}{0.33\textwidth}
\foreach \x in {চাল,ডাল,লবণ,তেল,মরিচ,পেঁয়াজ,রসুন,আদা,মুরগী,মশলা}
{
\ListItem{\x}\par\bigskip}
\end{minipage}

\begin{minipage}{0.33\textwidth}
\foreach \x in {চাল,ডাল,লবণ,তেল,মরিচ,পেঁয়াজ,রসুন,আদা,মুরগী,মশলা}
{
\ListItem{\x}\par\bigskip}
\end{minipage}

\vspace{2cm}
\begin{minipage}{0.33\textwidth}
\foreach \x in {চাল,ডাল,লবণ,তেল,মরিচ,পেঁয়াজ,রসুন,আদা,মুরগী,মশলা}
{
\ListItem{\x}\par\bigskip}
\end{minipage}
\begin{minipage}{0.33\textwidth}
\foreach \x in {চাল,ডাল,লবণ,তেল,মরিচ,পেঁয়াজ,রসুন,আদা,মুরগী,মশলা}
{
\ListItem{\x}\par\bigskip}
\end{minipage}
\begin{minipage}{0.33\textwidth}
\foreach \x in {চাল,ডাল,লবণ,তেল,মরিচ,পেঁয়াজ,রসুন,আদা,মুরগী,মশলা}
{
\ListItem{\x}\par\bigskip}
\end{minipage}
\end{document}

答案1

如果要重复相同的内容,请将其放入\savebox

enter image description here

代码:

\documentclass{article}
\usepackage{showframe}

\newsavebox{\MyBox}
\savebox{\MyBox}{%
    \begin{minipage}{0.30\textwidth}
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
        Ut purus elit, vestibu- lum ut, placerat ac, adipiscing vitae, fe- lis. 
        Curabitur dictum gravida mauris. 
        Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. 
        Donec vehicula augue eu neque.%
    \end{minipage}%
}%
\begin{document}
\noindent
\usebox{\MyBox}\hfill\usebox{\MyBox}\hfill\usebox{\MyBox}%
\end{document}

答案2

一个简单的方法是加载 multido 包。然后只需使用

\multido{}{# of iterations}{Stuff to iterate}

我没有安装孟加拉字体,但这里有一个类似的例子:

\documentclass{article}
\usepackage{multido}
\usepackage{booktabs}
\usepackage[a4paper,left=0cm,top=0.2cm,bottom=0cm,right=0cm]{geometry}
\usepackage{pgffor}
\newcommand{\ListItem}[1]{\underline{\makebox[5cm][l]{#1}}}
\newcommand{\minicontent}{\foreach \x in {first,a,b,c,d,last}{\ListItem{\x}\par\bigskip}}
\begin{document}
\noindent
\multido{}{9}{\begin{minipage}{0.33\textwidth}\minicontent\end{minipage}
}
\end{document}

这使:enter image description here

相关内容