调整 TikZ 绘图

调整 TikZ 绘图
\documentclass{scrartcl}

\usepackage{amsmath}
\usepackage{sfmath}

\usepackage{tikz}
\usetikzlibrary{positioning}
 \usetikzlibrary{calc}
 \usetikzlibrary{shadings}
\usetikzlibrary{shapes.geometric, angles,quotes,babel,3d}

\usepackage[most]{tcolorbox}
 \tcbuselibrary{skins,xparse}
 \tcbuselibrary{breakable}
\tcbset{
innenboxstyle/.style={
sidebyside adapt=right, 
bicolor,colback=gray!10, colbacklower=white,
fonttitle=\bfseries,
fontupper=\scriptsize,
 sharpish corners, colframe=gray!20!black, colbacktitle=gray!40,coltitle=black,
scale=1.0, 
sidebyside align=top seam,
left=0mm, 
valign lower=center, 
halign lower=center, 
},
seitenboxstyle/.style={
sidebyside, 
sidebyside align=top seam, 
sidebyside gap=3mm,
sharpish corners,
lower separated=false,
colframe=gray!10!black,colback=white,fonttitle=\bfseries
},
innenboxstylezwei/.style={
bicolor,colback=gray!10, colbacklower=white,
fonttitle=\bfseries,
fontupper=\scriptsize,
 sharpish corners, colframe=gray!20!black, colbacktitle=gray!40,coltitle=black,
scale=1.0,
sidebyside align=top seam,
left=0mm,
valign lower=center, 
halign lower=center,
},
}
% ====================================

\newcommand\titelbereich{Drawing}
\newcommand\textbereich{\subsubsection*{Area}
\begin{equation*}
A=g\cdot h
\end{equation*}
% here a dotted gray line
\subsubsection*{Circumference}
\begin{equation*}
u=2\cdot a+2\cdot b
\end{equation*}}
\newcommand\bildbereich{\begin{tikzpicture}[my angle/.style={font=\small, draw, angle eccentricity=1.75, angle radius=3mm}]
  \node (a) [trapezium,trapezium left angle=60, trapezium right angle=120, minimum width=30mm, draw, very thick, label=below:\scriptsize g, label=left:\scriptsize ] {};
  \draw [densely dashed, very thick] (a.north west) coordinate (a nw) -- (a nw |- a.south) node [midway,right] {$\scriptstyle h$} ;
  \coordinate (a blc) at (a.bottom left corner);
  \coordinate (a brc) at (a.bottom right corner);
 
%here a dotted, gray line with another parallelogramm below the line
\end{tikzpicture}}

% =====================================

\begin{document}
%========================
\tcbsidebyside[innenboxstyle, title={\titelbereich},]{\textbereich}{\bildbereich}
%========================
\end{document}

我必须在上面的图中添加以下内容:

(1)我需要在“面积”方程和“周长”方程之间画一条灰色虚线。

(2)此外,我需要在平行四边形的右下方画一条相同的线。线的下方应该还有另一个平行四边形。这个平行四边形的边分别是 a 和 b。

(3)两条虚线应处于同一高度。

我尝试过使用,\draw[dotted]但没有用。左侧和右侧都不起作用。这是一张草图: 在此处输入图片描述

答案1

编辑(1):

  • 不清楚你的实际桌子有多大
  • 它可以放在一页里吗?
  • 如果是,您可以使用tblr表格:

编辑:

  • 正如楼主在评论中抱怨的那样,第一列没有灰色填充,现在添加了这个,
  • 表格代码也进行了一些小改进(虚线命令移至表格前言)
\documentclass{scrartcl}

\usepackage{sfmath}
\usepackage{tabularray}

\usepackage{tikz}
\usetikzlibrary{angles,
                babel,
                calc,
                positioning,
                quotes,
                shadings, shapes.geometric,
                3d}
\tikzset{baseline=(current bounding box.center),
    my angle/.style = {draw, font=\small, 
                       angle eccentricity=1.75, angle radius=3mm},
    base/.style = {draw, thick},
    dashline/.style = {densely dashed, very thick},
    every edge quotes/.style = {auto=right, inner sep=1pt, font=\small},
    Trapezium/.style = {base, trapezium,
                        trapezium left angle=60, trapezium right angle=120,
                        minimum width=30mm}
        }
\begin{document}
\begin{center}
\begin{tblr}{hline{1,2,Z} = 1pt, vline{1,Z} = 1pt,
             hline{even[3-X]} = {dashed, fg=gray, 0.5pt},
             colspec = {Q[l, bg=gray!10, font=\bfseries]
                        Q[l, bg=gray!10, mode=math, rightsep=24pt]
                        Q[c]},
             cell{even[2]}{2,3} = {r=2}{},
             row{1}  = {bg=gray!30},
             row{2-Z}= {rowsep  = 4pt}
             }
\SetCell[c=3]{l}    Drawing &   &   \\
Area    &   A=g\cdot h          &  
        \tikz{  \node (a) [Trapezium] {};
                \draw [dashline] (a.north west)  to["$h$" '] (a.south west);
                \path   (a.bottom left corner)  to["$g$"] (a.bottom right corner);
            }   \\   
        &   &   \\         
Circumference
        &   u=2\cdot a+2\cdot b &
        \tikz{  \node (a) [Trapezium] {};
                \path   (a.top left corner)  to["$a$" ] (a.bottom left corner)
                        (a.bottom left corner)  to["$b$"] (a.bottom right corner);;
            }   \\
        &   &   \\
\end{tblr}
\end{center}
\end{document}
  • 如您所见,我为表中的所有图像定义了通用样式,
  • 两者tikzpicture都是从头开始绘制的。

在此处输入图片描述

编辑(2)

  • 改进了表格序言,并在表格跨越两页时添加了图像。
  • 如果需要扩展到几页,则longtblr表格如下:
  • 使用它,您需要删除center环境并将表序言更改为:
\begingroup
\DefTblrTemplate{firsthead, middlehead,lasthead}{default}{} % <---
\SetTblrStyle{contfoot-text}{font=\footnotesize\itshape, fg=gray1}
\begin{longtblr}{hline{1,2,Z} = 1pt, vline{1,Z} = 1pt,
                 hline{even[3-X]} = {dashed, fg=gray, 0.5pt},
                 colspec = {Q[l, bg=gray!10, font=\bfseries]
                            Q[l, bg=gray!10, mode=math, rightsep=24pt]
                            Q[c]},
                 cell{even[2]}{2,3} = {r=2}{},
                 row{1}  = {bg=gray!30},
                 row{2-Z}= {rowsep  = 4pt},
                 rowhead = 1
                 }
  • 表体中的偶数行以\\*
  • 在这种情况下,当表体中有八次重复上述示例的内容时,考虑到上述行终止的变化
Area    &   A=g\cdot h          &
        \tikz{  \node (a) [Trapezium] {};
                \draw [dashline] (a.north west)  to["$h$" '] (a.south west);
                \path   (a.bottom left corner)  to["$g$"] (a.bottom right corner);
            }   \\*   % <----
        &   &   \\
Circumference
        &   u=2\cdot a+2\cdot b &
        \tikz{  \node (a) [Trapezium] {};
                \path   (a.top left corner)  to["$a$" ] (a.bottom left corner)
                        (a.bottom left corner)  to["$b$"] (a.bottom right corner);;
            }   \\*   % <----
        &   &   \\

表为:

在此处输入图片描述

答案2

tcbitemize

在此处输入图片描述

\documentclass{scrartcl}
\usepackage[most]{tcolorbox}
\tcbset{
NoGaps/.style={boxsep=0pt, left=0pt, right=0pt, top=0pt, bottom=0pt},
enhanced,
}

\begin{document}
\begin{tcolorbox}[
NoGaps, sharp corners, 
before title=\vspace{1ex}\hspace{0.75ex}, after title=\vspace{1ex},% looks better
title={Main Title}, 
fonttitle=\bfseries,    coltitle=black,
colbacktitle=gray!40,
%colframe=black, 
boxrule=1.4pt,
]
\begin{tcbitemize}[
raster columns=100, % is equivalent to  100% 
raster equal height=rows,
sharp corners, boxrule=0pt, 
% NoGaps, % optional
enhanced,% needed for ...xxx...
raster row 1/.style={
borderline south={1.0pt}{0pt}{densely dashed}, % ...xxx... that
%bottomrule=3mm,  %  would enough  if 'dashed' is not  desired
},
raster column skip=0pt,
raster row skip=0pt,
raster before skip=0pt,
raster after skip=0pt,
colback=gray!20,
]
\tcbitem[raster multicolumn=75] Upper Left (75\% of width)
\tcbitem[raster multicolumn=25, colback=white] Upper Right (25\% of width)
\tcbitem[raster multicolumn=75] Lower Left
\tcbitem[raster multicolumn=25, colback=white] Lower Right \\ 1 \\ 2\\ 3 
\end{tcbitemize}
\end{tcolorbox}
\end{document}

相关内容