我正在尝试做以下事情。我认为我应该使用新帖子,因为上一篇帖子非常不清楚。
我非常感谢大家的帮助。谢谢
我从这个建议开始,并试图修改它,但很难让它达到我想要的效果,框很窄,这种类型的代码很难。我只用过表格。
\documentclass[
a5paper,
% pagesize,11pt,% both are default and therefore not needed
bibliography=totoc,% bibtotoc is deprecated and therefore replaced according
% to the warning message
numbers=noenddot,% pointlessnumbers is deprecated and therefore replaced
% according to the warning message
headings=normal,% normalheadings is deprecated and therefore replaced
% according to the warning message
DIV=9,twoside=false,
headsepline,footsepline,footinclude=false,% see the KOMA-Script manual
headheight=87pt,% not used, to not lower the header, but this results in a warning
footheight=52pt, % no longer needed, because the lines are not part of the footer
]{scrbook}
\KOMAoptions{DIV=last}
\usepackage{trajan}
\usepackage{setspace}
\linespread{1.05}
\KOMAoptions{DIV=last}% moved according to the KOMA-Script manual, because it
% makes no sense before changing font an linespread.
\usepackage{graphicx}
\usepackage[%
autoenlargeheadfoot=false,% only warn but don't change height reserved for header or footer
manualmark,% or maybe automark, this is not clear due to missing information
% in the question.
plainheadsepline,plainfootsepline,% See the KOMA-Script manual for more information
]{scrlayer-scrpage}
\usepackage{geometry}
\geometry{
a5paper,
total={100mm,200mm}, %not sue what this line is either.
left=15mm,
right=15mm,
top=30mm,
bottom=35mm,
headsep=2mm,
}
\usepackage{xcolor}
\usepackage{efbox}
\usepackage{makecell}
\usepackage{tasks}
\counterwithin{equation}{section}
\newcounter{example}
\counterwithin*{example}{section}
\newlength \templgtha
\newlength \templgthb
\newlength \templgthc
\newsavebox \tempboxa
\setlength \templgthb {\textwidth}
\setlength \templgthc {\textwidth}
\addtolength \templgthc {-10pt}
\newenvironment{example}{%
\stepcounter{example}%
\par\vspace{5pt}\noindent
\sbox \tempboxa{%
\efbox[font=\normalfont\bfseries,linecolor=cyan,linewidth=.9pt]{Example~\theexample}%
}%
\settowidth \templgtha {\usebox \tempboxa}%
\addtolength \templgthb {-\templgtha}%
\usebox \tempboxa
{\color{cyan}\vrule width\templgthb height0.9pt depth0.3pt}\par\vspace{10pt}\noindent\rmfamily
}{%
\par\noindent
{%
\color{cyan}%
\vrule width\templgthc height0.3pt depth0.9pt
\vrule width10pt height2pt depth2pt
}\par
}
\setcellgapes{5pt}
\newcolumntype{C}{>{\color{black}}c}
\renewcommand\theadalign{CCC}
\begin{document}
\begin{example}
\begin{tasks}
\task $(x+2)(x+3)$
\begin{center}
\color{red}
\begin{tabular}{%
*{3}{!{\vrule width 1pt}C}!{\vrule width 1pt}
}
\Xcline{2-3}{1pt}
\multicolumn{1}{c!{\vrule width 1pt}}{\thead{$\times$}} & \thead{$x$} & \phantom{xxx} \thead{$2$} \phantom{xxx}\\\Xhline{1pt}
\thead{$x$} & $x^{2}$ & $2x$ \\\Xhline{1pt}
\thead{$3$} & $3x$ & $6$ \\\Xhline{1pt}
\end{tabular}
\end{center}
\end{tasks}
\end{example}
\end{document}
答案1
这是使用纯 TikZ 的简单自动解决方案(但不是通用解决方案)。您可以根据需要调整长度参数a
, b
, 。c
\documentclass[a5paper]{scrbook}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}[declare function={a=2;b=1;c=1.5;}]
\draw[line width=1.5pt,blue]
(-1,0)-|(1+a,-b-c)-|(0,1)
(1,0)--(1,-b-c) (0,-b)--(1+a,-b)
;
\path
(-.5,.5) node{$\times$} ++(1,0) node{$x$} +(.5+a/2,0) node{$3$}
(-.5,-b/2) node{$x$} ++(1,0) node{$x^2$} +(.5+a/2,0) node{$3x$}
(-.5,-b-c/2) node{$2$} ++(1,0) node{$2x$} +(.5+a/2,0) node{$6$}
;
\end{tikzpicture}
\end{center}
\end{document}
答案2
这是带有tabularray
软件包的解决方案。单元格宽 2cm,高 1cm,规则为红色,厚度为 1pt,但所有这些都可以轻松更改。我拿走了一些未使用的东西。
\documentclass[
a5paper,
% pagesize,11pt,% both are default and therefore not needed
bibliography=totoc,% bibtotoc is deprecated and therefore replaced according
% to the warning message
numbers=noenddot,% pointlessnumbers is deprecated and therefore replaced
% according to the warning message
headings=normal,% normalheadings is deprecated and therefore replaced
% according to the warning message
DIV=9,twoside=false,
headsepline,footsepline,footinclude=false,% see the KOMA-Script manual
headheight=87pt,% not used, to not lower the header, but this results in a warning
footheight=52pt, % no longer needed, because the lines are not part of the footer
]{scrbook}
\KOMAoptions{DIV=last}
\usepackage{trajan}
\usepackage{setspace}
\linespread{1.05}
\KOMAoptions{DIV=last}% moved according to the KOMA-Script manual, because it
% makes no sense before changing font an linespread.
\usepackage{graphicx}
\usepackage[%
autoenlargeheadfoot=false,% only warn but don't change height reserved for header or footer
manualmark,% or maybe automark, this is not clear due to missing information
% in the question.
plainheadsepline,plainfootsepline,% See the KOMA-Script manual for more information
]{scrlayer-scrpage}
\usepackage{geometry}
\geometry{
a5paper,
total={100mm,200mm}, %not sue what this line is either.
left=15mm,
right=15mm,
top=30mm,
bottom=35mm,
headsep=2mm,
}
\usepackage{tabularray}
\usepackage{xcolor}
\usepackage{efbox}
\usepackage{tasks}
\counterwithin{equation}{section}
\newcounter{example}
\counterwithin*{example}{section}
\newlength \templgtha
\newlength \templgthb
\newlength \templgthc
\newsavebox \tempboxa
\setlength \templgthb {\textwidth}
\setlength \templgthc {\textwidth}
\addtolength \templgthc {-10pt}
\newenvironment{example}{%
\stepcounter{example}%
\par\vspace{5pt}\noindent
\sbox \tempboxa{%
\efbox[font=\normalfont\bfseries,linecolor=cyan,linewidth=.9pt]{Example~\theexample}%
}%
\settowidth \templgtha {\usebox \tempboxa}%
\addtolength \templgthb {-\templgtha}%
\usebox \tempboxa
{\color{cyan}\vrule width\templgthb height0.9pt depth0.3pt}\par\vspace{10pt}\noindent\rmfamily
}{%
\par\noindent
{%
\color{cyan}%
\vrule width\templgthc height0.3pt depth0.9pt
\vrule width10pt height2pt depth2pt
}\par
}
\begin{document}
\begin{example}
\begin{tasks}
\task $(x+2)(x+3)$
\begin{center}
\NewColumnType{C}{Q[c,wd=2cm]}
\NewRowType{M}{Q[m,ht=1cm]}
\begin{math}
\begin{tblr}{colspec={*3C},rowspec={*3M},
hlines={1-Z}{red,1pt},vlines={1-Z}{red,1pt},
vline{1}={1}{0pt},hline{1}={1}{0pt}
}
\times & x & 2 \\
x & x^2 & 2x \\
3 & 3x & 6 \\
\end{tblr}
\end{math}
\end{center}
\end{tasks}
\end{example}
\end{document}