来自 Indesign 的启发性练习表

来自 Indesign 的启发性练习表

我想创建这张由 Adob​​e Indesign 制作的表格

有人可以用乳胶制作它吗?

在此处输入图片描述

这是我的代码:

\documentclass[12pt,a4paper,twocolumn]{report}
\usepackage[margin=0.5in]{geometry}
\usepackage[french]{babel}
\usepackage{fontspec}
\usepackage{graphicx}
\usepackage{amsthm,amssymb,amsfonts,mathtools}
\usepackage[utf8]{inputenc}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{amssymb}
\usepackage{array}
\usepackage{graphicx}
\setlength{\columnseprule}{0.5pt}
\thispagestyle{empty}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%head%%%%%%%%%%%%%%%%%%%%%%%
\twocolumn[ 
  \begin{@twocolumnfalse}
 \begin{center}
 \fbox{\Large Exercise Sheets}
\end{center}
    \hrulefill
\end{@twocolumnfalse}
  ]
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \fbox{ Exercise $1$:}\\
 Compute the following limits
\begin{multicols}{2}
\begin{enumerate}
\item $\lim_{x\to 2}\dfrac{4x^{3}-5x-22}{x^{2}-x-2}$
\item $\lim_{x\to 0^{+}}\dfrac{x-\sqrt{x}}{x+\sqrt{x}}$
\item $\lim_{x\to 1}\dfrac{\sqrt{x+3}+\sqrt{x}-3}{x-1}$
\item $\lim_{x\to 2}\dfrac{x^{2}\sqrt{x+2}-8}{4-x^{2}}$
\end{enumerate}
\end{multicols}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\fbox{ Exercise $2$:}\\
Let $n\in\mathbb{N}^{*}$
\begin{enumerate}
    \item calculate : ${\displaystyle \lim_{x\to 0}\dfrac{1-\cos(x)\cos(2x)\ldots+\cos(nx)}{x^2} }$
    \item b
    \item c
    \item d
    \item e
    \item f
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}

答案1

我对答案进行了大幅修改。结果如下。代码中有一些注释可以提供帮助。

使用tikz.styeso-pic.sty您可以实现类似的功能,而无需手动拆分文本。这是一个概念验证,我稍后有机会时会添加它。不过,这可能是一个开始。

% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = XeLaTeX


\documentclass{article}

\usepackage{tikz}
\usepackage{multicol}
\usepackage{lipsum}
\usepackage{tikzpagenodes}
\usepackage{eso-pic}
\usepackage{enumitem}
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage[margin=1in]{geometry}

\setmainfont{STIX Two Text}
\setmathfont{STIX Two Math}
\setsansfont{Helvetica Neue}[Scale=0.9]

\usetikzlibrary{calc}
\usetikzlibrary{shapes.multipart}

\newcounter{exrc}

\newcommand{\exstep}{%
    \stepcounter{exrc}%
    \tikz[baseline]\node[anchor=base,%
        rectangle split,
        rectangle split parts=2,
        draw=gray,
        thick,
        rectangle split horizontal,
        rectangle split part fill={gray,white},
        inner sep=3pt] (exx) at (0,0)
        {\textcolor{white}{\bfseries \extype}\nodepart{two}\theexrc};
}

\AddToShipoutPictureBG{%
    \begin{tikzpicture}[remember picture,overlay]
        \draw[thick,rounded corners]
            ($(current page text area.south west)+(-12pt,-12pt)$)
                rectangle 
                ($(current page text area.north east)+(12pt,12pt)$);
        \node[white,fill=gray,rounded corners]
                at ($(current page text area.north)+(0,12pt)$) 
                %% Change `Exercises' to suit
                {\bfseries\sffamily\hspace*{1em}Exercises\hspace*{1em}};
    \end{tikzpicture}
}

%% There are two environments, `exci` for exercises using `enumerate`,
%% and `exct` for text exercises that do not use `enumerate`.
%% Both have an optional argument to change the name of the
%% exercise on the fly. See the included examples.

\newenvironment{exci}[2][Exercise]{%
    \def\extype{#1}%
    \leavevmode\exstep\par
    \smallskip
    #2
    \begin{enumerate}[leftmargin=*,noitemsep,nosep]
}{%
    \end{enumerate}
    \bigskip
    \def\extype{Exercise}%
}

\newenvironment{exct}[1][Exercise]{%
    \def\extype{#1}%
    \leavevmode\exstep\par
    \smallskip
    }{%
        \bigskip
        \def\extype{Exercise}%
}

\setlength{\columnseprule}{0.4pt}
\parindent0pt

\begin{document}

\begin{multicols*}{2}

\begin{exci}{Calculate the following limits:}
\item $\lim\displaylimits_{x \to2}\frac{4x^3-5x-22}{x^2-x-2}$
\item $\lim\displaylimits_{\substack{x \to 0\\x > 0}}\frac{x-\sqrt{x}}{x+\sqrt{x}}$
\item $\lim\displaylimits_{x \to 0}\frac{\sqrt{x+3}+\sqrt{x}-3}{x-1}$
\item $\lim\displaylimits_{x \to 2}\frac{x^2\sqrt{x+2}-8}{4-x^2}$
\end{exci}

\begin{exci}{Let $n \in \mathbb{N}^*$}
\item Calculate: $\lim_{x \to 0}\frac{1-\cos(x)\cos(2x)\cdots+\cos(nx)}{x^2}$
\item Calculating as a function of n the following limit: $\lim_{x \to 1}\frac{1+x+x^2+\cdots+x^n-n}{(2-x)^n-1}$
\end{exci}

\begin{exct}
Let $f$ be the continuous function on $[0,+\infty]$ having a finite limit at $+\infty$. 

Show that $f$ is bounded.
\end{exct}

\begin{exci}{This is a $E=mc^2$ test of this environment}
\item True
\item False
\end{exci}

\begin{exci}[Extra credit]{This is a $E=mc^2$ test of this environment}
\item True
\item False
\end{exci}

\begin{exct}[Exercise*]
This is yet another one without an enumerate.
\end{exct}

\end{multicols*}

\end{document}

毫无疑问,改进是可能的,而且是受欢迎的。请注意,我已将 STIX 2.0 与 XeLaTeX 和 一起使用unicode-math.sty

更精准的实施

我修正了我在实施格式时遇到的一个问题。

答案2

我认为这种格式的主要问题是你想要在装饰边界框内采用两列格式。

和多列的组合tcolorbox是可能的,但需要满足某些条件。可破坏元素tcolorbox可以在多列中使用,但框会应用于每一列。您也可以multicol在内部使用环境tcolorbox,但前提是框不可破坏。所以,我认为没有简单的解决方案。

但如果您不介意使用非自动解决方案,tcolorbox也可以使用。以下代码显示了基于magazineraster库的部分非自动解决方案。

magazine库允许将文本拆分并存储在多个框中,以便以后使用。使用此工具,可以将文本拆分为“一列宽 x 固定高度”的片段。

\begin{tcolorbox}[blanker, 
width=.4\textwidth,      %<-------- column width
breakable,
break at=.93\textheight,       %<----- column height
height fixed for=first and middle,
watermark text=\arabic{tcbbreakpart},
reset box array,
store to box array,]
\lipsum[1-7]              %<---- Here is the text
\end{tcolorbox}

一旦获得了 fragment 中的所有文本,就可以手动将其组合成breakable可以像其他任何文本一样进行装饰的栅格tcolorbox。在这种情况下,盒装的 tcbitemize 环境可以完成这项工作。

\begin{tcboxeditemize}[
     blanker, raster columns=2, sharp corners, 
     halign=center, raster valign=top]   %<--- inner boxes format and distribution
     {breakable, colback=yellow!10, 
      fonttitle=\bfseries, 
      attach boxed title to top center={yshift*=-\tcboxedtitleheight/2},      
      title=Exercicies, 
      overlay={\draw [shorten >=4mm, shorten <=4mm] 
           (frame.north)--(frame.south);}}  %<--- Format for outer box
  %--- Raster contents ---%
  \tcbitem\consumeboxarray{1}   %<---- First column
  \tcbitem\consumeboxarray{2}   %<---- Second column
  \tcbitem\consumeboxarray{3}   % ...
  \tcbitem\consumeboxarray{4}
\end{tcboxeditemize}

不幸的是,我不知道如何foreach在 a 中使用 a tcbraster,所以我们必须手动\tcbitem\consumebnoxarray{...}在文本中插入尽可能多的行作为片段。

最终结果如下:

在此处输入图片描述

如果您知道有多少个片段,倒数第二个片段可能会更短,这样您就会得到更加平衡的最后一页,但这不在本解决方案的范围之内。

此外,代码中省略了练习的内部格式。此代码只是尝试展示一个可能的起点。

获取前一张图像的完整代码是:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{multicol}
\usepackage{lipsum}

\begin{document}
\begin{tcolorbox}[blanker, 
width=.4\textwidth,
breakable,
break at=.93\textheight,
height fixed for=first and middle,
watermark text=\arabic{tcbbreakpart},
reset box array,
store to box array,]
\lipsum[1-7]
\end{tcolorbox}

\begin{tcboxeditemize}[blanker, raster columns=2, sharp corners, halign=center, raster valign=top]{breakable, colback=yellow!10, fonttitle=\bfseries, attach boxed title to top center={yshift*=-\tcboxedtitleheight/2},  title=Exercicies, overlay={\draw [shorten >=4mm, shorten <=4mm] (frame.north)--(frame.south);}}
\tcbitem\consumeboxarray{1}
\tcbitem\consumeboxarray{2}
\tcbitem\consumeboxarray{3}
\tcbitem\consumeboxarray{4}
\end{tcboxeditemize}
\end{document}

相关内容