一行中有多个多行框,溢出时换行

一行中有多个多行框,溢出时换行

我希望在一行中放置多个带有多行内容的框,当框溢出时可以换行。

我的想法是构建一个自定义的贡献者 / 审阅者环境,我也可以将其与 TeX4ht 一起使用:

\documentclass[a4paper]{report}

\usepackage{pgffor}

\newcommand{\ccReviewer}[1]{%
    \hbox{#1}
}
\newcommand{\ccAffiliation}[1]{%
    \hbox{#1}
}
\newcommand{\ccReviewersList}[1]{%
    \hbox{%
        \foreach \reviewer / \affiliation in #1{%
            \vbox{
                \ccReviewer{\reviewer}%
                \ccAffiliation{\affiliation}
            }
        }
    }
}


\begin{document}
\begin{center}
    {\large Contributors and Reviewers}\\
    \vspace{5mm}
    \def\ccReviewers{%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation%
    }
    \ccReviewersList{\ccReviewers}
\end{center}

\end{document}

这是当前输出:

加拿大信贷评级协会

答案1

\documentclass[a4paper]{report}

\usepackage{pgffor,stackengine}

\newcommand{\ccReviewer}[1]{%
    \hbox{#1}
}
\newcommand{\ccAffiliation}[1]{%
    \hbox{#1}
}
\newcommand{\ccReviewersList}[1]{%
        \foreach \reviewer / \affiliation in #1{%
            \Longstack[l]{%
                \ccReviewer{\reviewer}
                \ccAffiliation{\affiliation}
            }
        }
}
\begin{document}
\begin{center}
    {\large Contributors and Reviewers}\\
    \vspace{5mm}
    \def\ccReviewers{%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation%
    }
    \ccReviewersList{\ccReviewers}
\end{center}
\end{document}

在此处输入图片描述

您可以进一步简化它:

\documentclass[a4paper]{report}

\usepackage{pgffor,stackengine}

\newcommand{\ccReviewersList}[1]{%
    \foreach \reviewer / \affiliation in #1{%
        \addstackgap[4pt]{\Longstack[l]{\reviewer{} \affiliation}}\hspace{4pt} 
    }
}
\begin{document}
\begin{center}
    {\large Contributors and Reviewers}\\
    \vspace{5mm}
    \def\ccReviewers{%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation,%
        Author/Affiliation%
    }
    \ccReviewersList{\ccReviewers}
\end{center}
\end{document}

...或者甚至pgffor用替换listofitems,这样你就不需要列表%中的预告片了\ccReviewers

\documentclass[a4paper]{report}

\usepackage{stackengine,listofitems}

\newcommand{\ccReviewersList}[1]{%
    \setsepchar[?]{,?/}%
    \readlist*\authlist{#1}%
    \foreachitem\x\in\authlist[]{%
        \addstackgap[4pt]{%
        \Longstack[l]{\authlist[\xcnt,1] \authlist[\xcnt,2]}}\hspace{4pt}
    }
}
\begin{document}
\begin{center}
    {\large Contributors and Reviewers}\\
    \vspace{5mm}
    \def\ccReviewers{
        Author/Affiliation,
        Author/Affiliation,
        Author/Affiliation,
        Author/Affiliation,
        Author/Affiliation,
        Author/Affiliation,
        Author/Affiliation,
        Author/Affiliation,
        Author/Affiliation,
        Author/Affiliation,
        Author/Affiliation
    }
    \ccReviewersList{\ccReviewers}
\end{center}
\end{document}

相关内容