
我正在為程式設計課程製作交互圖。對於一組對象,我需要繪製重疊的矩形,大致如下:
有一個發布重疊填充這看起來非常接近我想要的,但我不知道如何使用其他矩形的樣式。
這是我所擁有的最小版本:
\documentclass{article}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{positioning}
\title{Interaction Diagram - Add Book}
\author{}
\begin{document}
\begin{center}
\begin{tikzpicture}[
auto,
block/.style = {
minimum width = 9em,
rectangle,
draw=black,
align=center,
rounded corners
}
]
\node[block, below = 2cm of start] (controller) {\underline{: SystemController}};
\node[block, below = 2cm of controller] (system) {\underline{: System}};
% the following line should be the doubled up rectangles.
\node[block, below = 2cm of system] (books) {Books};
\end{tikzpicture}
\end{center}
\end{document}
答案1
我想,實際上你喜歡這樣的東西:
或者
或者
對於最後一張圖片,我使用以下程式碼:
\documentclass[tikz,
border= 3mm]{standalone}
\usetikzlibrary{positioning,shadows}
\begin{document}
\begin{tikzpicture}[
book/.style = {rectangle, draw, rounded corners, fill= white,
text width=9em, align= center,
copy shadow={draw, fill=gray,
shadow xshift=0.5mm, shadow yshift=-0.5mm}
}
]
\node[book] (books) {Books};
\end{tikzpicture}
\end{document}
在程式碼中我使用 TikZ 函式庫shadows
。
答案2
這是一種沒有tikz
.的尺寸\rule
和第一個參數\stackengine
將允許不同的框大小和偏移。
在本例中,框的大小為 30pt x 30pt,水平偏移 4pt,垂直偏移 3pt。框線厚度為預設值\fboxrule
。
\documentclass[12pt]{article}
\usepackage{xcolor,stackengine}
\fboxsep=-\fboxrule
\begin{document}
\stackengine{3pt}{\rule{4pt}{0pt}\fbox{\textcolor{white}{\rule{30pt}{30pt}}}}
{\fbox{\textcolor{white}{\rule{30pt}{30pt}}}}
{O}{l}{F}{F}{L}
\end{document}