我想创建一个与第一个例子类似的工作表。
下面的代码遇到三个问题。
- 它不能被打破
- 两个示例未顶部对齐
- 该命令创建点线,有时会产生错误。
请建议我其他方法或更正以下代码。非常感谢!
\documentclass[12pt]{book}
\usepackage[paperwidth=21cm,paperheight=29.7cm,top=2.5cm,bottom=2cm,left=2cm,right=1.5cm]{geometry}
\setlength{\parindent}{0.6cm}
\setlength{\parskip}{6pt}
\linespread{1.1}
\usepackage{tikz}
\usepackage{adjustbox}
\newlength\myheight
\newlength{\myheightn}
\usepackage{multido}
\newcommand{\twocols}[2]{
\par\noindent
\begin{adjustbox}{minipage=[t]{0.5\linewidth},gstore totalheight=\myheight,margin=\fboxsep+\fboxrule}
\vspace*{0pt}
{\bfseries\fontfamily{qag}\selectfont Example 1}. #1
\end{adjustbox}
\hspace*{\fboxsep}
\begin{adjustbox}{minipage=[t][\myheight]{0.5\linewidth}}
\vspace*{0pt}
\begin{adjustbox}{minipage=[t]{0.95\linewidth},gstore totalheight=\myheightn,margin=\fboxsep+\fboxrule}
{\bfseries\fontfamily{qag}\selectfont Example 2}. #2
\end{adjustbox}
\edef\sodongt{\the\numexpr\dimexpr (\myheight-\myheightn)/(\dimexpr 1.1\baselineskip\relax) \relax\relax}
\pgfmathsetmacro{\sodong}{int(\sodongt-1)}
\par
\noindent \makebox[0.975\linewidth]{{\bfseries\fontfamily{qag}\selectfont\color{blue}Solution}:\dotfill}
\multido{}{\sodong}{\vspace*{2pt}\noindent\makebox[0.975\linewidth]{\dotfill}\newline}
\end{adjustbox}
}
\usepackage{lipsum}
\begin{document}
\twocols{\lipsum[12]}{a}
\end{document}
答案1
以下涉及水平和垂直引线。
缺点:
无法进行分页。
\baselineskip
由于虚线是作为垂直引线绘制的,因此不会考虑左侧的垂直跳跃。
\documentclass[12pt]{book}
\usepackage[paperwidth=21cm,paperheight=29.7cm,top=2.5cm,bottom=2cm,left=2cm,right=1.5cm]{geometry}
\setlength{\parindent}{0.6cm}
\setlength{\parskip}{6pt}
\linespread{1.1}
%\usepackage{tikz}
\usepackage{xcolor}
\usepackage{adjustbox}
\newlength\myheight
\makeatletter
\DeclareRobustCommand\MyDotfill{%
% don't use \cleaders as in \dotfill but use \leaders
\leavevmode\leaders\hb@xt@ .44em{\hss.\hss}\hfill\kern\z@
}%
\newcommand\Mysavedprevdepth{}%
\makeatother
\newcommand{\twocols}[2]{%
\par\noindent
\begin{adjustbox}{minipage=[t]{\dimexpr.5\linewidth-2\fboxsep-2\fboxrule-.5\fboxsep\relax},gstore totalheight=\myheight,margin=\fboxsep+\fboxrule}%
{\fontfamily{qag}\textbf{Example 1.}} #1\par\xdef\Mysavedprevdepth{\the\prevdepth}%
\end{adjustbox}%
\hspace*{\fboxsep}%
\begin{adjustbox}{minipage=[t][\myheight]{\dimexpr.5\linewidth-2\fboxsep-2\fboxrule-.5\fboxsep\relax},margin=\fboxsep+\fboxrule}%
{\fontfamily{qag}\textbf{Example 2.}} #2\par
\vbox{\hbox to\hsize{\fontfamily{qag}\textbf{\color{blue}Solution:}\MyDotfill}}%
\kern-\prevdepth
\xleaders\vbox to\baselineskip %<-\baselineskip is the vertical distance between dotted lines. You can use any other value as well.
{\vfill\hbox to\hsize{\MyDotfill}}\vfill
\kern\Mysavedprevdepth
\end{adjustbox}%
}%
\usepackage{lipsum}
\begin{document}
\twocols{\lipsum[12]}{a}
\end{document}
答案2
有很多方法可以做到这一点。这是一个简单的方法minipage
:
\documentclass[12pt]{book}
\begin{document}
\begin{minipage}[t]{\linewidth}
\begin{minipage}[t]{0.4\linewidth}
\textbf{Example 1.}
Lorem ipsum dolor sit amet consectetuer Proin Curabitur condimentum vel Vivamus. Cursus dui vitae et facilisis Mauris sociis auctor elit interdum pede. Tristique ipsum elit ut nibh diam eget in accumsan a Lorem. Habitasse tempor dui dui dapibus justo consectetuer parturient est vitae wisi.
\end{minipage}
\begin{minipage}[t]{0.4\linewidth}
\textbf{Example 2.} Here's the problem to be solved.\\
Solution: \dotfill \\
\hspace*{-0.5em} \dotfill \\ % use as many as you need
\hspace*{-0.5em} \dotfill \\
\hspace*{-0.5em} \dotfill \\
\hspace*{-0.5em} \dotfill \\
\hspace*{-0.5em} \dotfill \\
\hspace*{-0.5em} \dotfill \\
\hspace*{-0.5em} \dotfill
\end{minipage}
\end{minipage}
\end{document}
结果: