使用 Shapepar 包创建等腰梯形段落

使用 Shapepar 包创建等腰梯形段落

这篇文章与以下内容相关以梯形形式高效显示段落shapepar其中一条评论中建议了这个包。

考虑一下代码

\documentclass[10pt]{book}
\usepackage{showframe}
\usepackage{shapepar,varwidth}

\def\trapezoiddownshape{%
  {0}% centerline is at x = 0
  {0}b{0}\\ %begin at (0, 0)
  {0}t{0}{3}\\ %text at y = 0, width = 3
  {2}t{0}{1}\\ %text at y = 2, width = 1
  {2}e{1} % end at (1,2)
}
\def\trapezoiddownpar#1{\Shapepar\trapezoiddownshape #1\unskip\ .\par}

\begin{document}
\vspace*{\fill}

\begin{center}
  \begin{varwidth}{\linewidth}
    \trapezoiddownpar{Lorem ipsum dolor sit amet, consectetur adipiscing 
      elit. Ut porttitor magna posuere tristique interdum. Maecenas ac nisi rutrum, tincidunt ante a, cursus est. Pellentesque dui ligula, maximus quis viverra sit amet, cursus sed urna. Donec eu erat sed justo cursus tristique non quis nisi. Suspendisse dapibus lorem nec laoreet interdum. Duis sit amet leo sagittis, tincidunt elit in, imperdiet diam. Nulla mi justo, tincidunt a ullamcorper eget, consequat ut odio. Aliquam erat volutpat. Suspendisse potenti. Aenean tristique arcu orci, sit amet dignissim ligula elementum vitae. Praesent auctor augue eu lacus tempor maximus. Quisque auctor, odio eu laoreet congue, mi massa facilisis nisi, a faucibus arcu nisi egetet ex}
  \end{varwidth}
\end{center}

\vfill

\end{document}

产生输出

在此处输入图片描述

问题:有人能建议我如何修改代码,以便生成一个等腰梯形(即底角相等的梯形)的段落吗?我还没搞清楚如何做到这一点。

评论:MWE 中指定的文本宽度可以修改。我用 编译了代码pdflatex

谢谢。

答案1

我注释掉了形状本身不需要的部分,调整了一些坐标。它适用于 documentclassesbookarticle

结果

%\documentclass[10pt]{article}
\documentclass[10pt]{book}% works with both classes
%\usepackage{showframe}
%\usepackage{shapepar,varwidth}
\usepackage{shapepar}

\def\trapezoiddownshape{%
  {0}% centerline is at x = 0% <<< no
  {0}b{1.5}\\ %begin at (0, 0)% <<<
  {0}t{0}{3}\\ %text at y = 0, width = 3
  {2}t{1}{1}\\ %text at y = 2, width = 1% <<<
  {2}e{1} % end at (1,2)
}
\def\trapezoiddownpar#1{\Shapepar\trapezoiddownshape #1\unskip\ .\par}

\begin{document}
\vspace*{\fill}

%\begin{center}
%  \begin{varwidth}{\linewidth}
    \trapezoiddownpar{Lorem ipsum dolor sit amet, consectetur adipiscing 
      elit. Ut porttitor magna posuere tristique interdum. Maecenas ac nisi rutrum, tincidunt ante a, cursus est. Pellentesque dui ligula, maximus quis viverra sit amet, cursus sed urna. Donec eu erat sed justo cursus tristique non quis nisi. Suspendisse dapibus lorem nec laoreet interdum. Duis sit amet leo sagittis, tincidunt elit in, imperdiet diam. Nulla mi justo, tincidunt a ullamcorper eget, consequat ut odio. Aliquam erat volutpat. Suspendisse potenti. Aenean tristique arcu orci, sit amet dignissim ligula elementum vitae. Praesent auctor augue eu lacus tempor maximus. Quisque auctor, odio eu laoreet congue, mi massa facilisis nisi, a faucibus arcu nisi egetet ex}
%  \end{varwidth}
%\end{center}

\vfill

\end{document}

相关内容