如何在 minipage 中绘制文本下方的网格线?

如何在 minipage 中绘制文本下方的网格线?

我想要实现如下所示的效果:

在此处输入图片描述

但我唯一能得到的ulem是:

在此处输入图片描述

使用下面的代码:

\documentclass[12pt]{report}
\usepackage{ulem}

\begin{document}
\begin{center}
  \begin{minipage}{.6\textwidth}

    \uline{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam non
    vulputate neque, sit amet dictum dolor. Vestibulum auctor ante nec arcu 
    faucibus lacinia.}

    \begin{center}
      \uline{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam non
      vulputate neque, sit amet dictum dolor. Vestibulum auctor ante nec arcu 
      faucibus lacinia.}
    \end{center}

  \end{minipage}
\end{center}
\end{document}

答案1

该解决方案用于\vbox格式化文本并\vsplit为每行添加下划线。

\documentclass[12pt]{report}
%\usepackage{ulem}

\newcommand{\lined}[1]% #1 = paragraph text
{\bgroup
  \setbox0=\vbox{\strut #1\strut}%
  \dimen0=0pt
  \loop\ifdim\ht0>0pt
    \dimen1=\dimexpr\ht0 - \baselineskip\relax
    \setbox1=\vsplit0 to \ht\strutbox
    \advance\dimen1 by -\ht0
    \noindent\raisebox{-\dimen0}[\ht\strutbox][\dp\strutbox]{\box1}%
    %\llap{\the\dimen0~\rule{\textwidth}{0.5pt}}% show baseline
    \advance\dimen0 by \dimen1
    \vspace{-0.2ex}\hrule\vskip 0.2ex % aesthetic tweak
  \repeat
\egroup}


\begin{document}
\begin{center}
  \begin{minipage}{.6\textwidth}
    \parindent=\bibindent
    %\huge
    \lined{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam non
    vulputate neque, sit amet dictum dolor. Vestibulum auctor ante nec arcu 
    faucibus lacinia.}

    \begin{center}
      \lined{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam non
      vulputate neque, sit amet dictum dolor. Vestibulum auctor ante nec arcu 
      faucibus lacinia.}
    \end{center}

  \end{minipage}
\end{center}
\end{document}

演示

相关内容