我正在寻找排版类似于这个的图表:
(来源:纸张尺寸网站)
对于我的图表而言,不同之处在于我不需要“A0”覆盖 - 并且...我想要的是乳胶中的数学表达式,整齐排版并居中,而不是毫米尺寸和 A 数。
我考虑过使用 Xfig - 但定位数学表达式很繁琐/棘手/需要手动操作。我考虑过使用 Inkscape - 但这使得包含数学表达式变得非常困难。我考虑过使用 TikZ - 但我找不到这种(近似)样式的任何示例图。
我倾向于仅使用 Latex 来实现这一点(即不使用 GUI 图形工具来绘制它),但我不知道从哪里开始。有没有人能给我举一个合适的例子?
答案1
更新
为了标记节点的维度,可以手动“绘制”它,如下例所示(需要arrows
库):
\begin{tikzpicture}
\node(n)[draw,minimum size=3cm]{$e=me^2$};
\draw[|<->|,>=latex]([yshift=5pt]n.north west)--([yshift=5pt]n.north east)
node[above,midway]{3cm};
\draw[|<->|,>=latex]([xshift=-5pt]n.south west)--([xshift=-5pt]n.north west)
node[above,midway,rotate=90]{3cm};
\end{tikzpicture}
这可以通过定义两个键markwd
和来简化markht
:
markwd/.style={
append after command={
\pgfextra{%
\begin{pgfinterruptpath}
\draw[|<->|,>=latex]
([yshift=5pt]\tikzlastnode.north west)--([yshift=5pt]\tikzlastnode.north east)
node[draw=none,midway,above]{#1};
\end{pgfinterruptpath}}}
},
markht/.style={
append after command={
\pgfextra{%
\begin{pgfinterruptpath}
\draw[|<->|,>=latex]
([xshift=-5pt]\tikzlastnode.south west)--([xshift=-5pt]\tikzlastnode.north west)
node[draw=none,midway,rotate=90,above]{#1};
\end{pgfinterruptpath}}}
},
因此,下面的代码将重现上面的图片:
\begin{tikzpicture}
\node(n)[draw,minimum size=3cm,markwd={3cm},markht={3cm}]{$e=me^2$};
\end{tikzpicture}
为了进一步简化,可以定义一个dim={<wd>}{<ht>}
键,其第一个参数设置节点的宽度,第二个参数设置高度:
dim/.style 2 args={minimum width=#1,minimum height=#2},
以下示例说明了如何在@StevenBSegletes 的示例中标记尺寸(请注意,yshift
需要进行一些细微的调整):
完整示例
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzset{
every node/.style={draw},
dim/.style 2 args={minimum width=#1,minimum height=#2},
markwd/.style={
append after command={
\pgfextra{%
\begin{pgfinterruptpath}
\draw[|<->|,>=latex]
([yshift=5pt]\tikzlastnode.north west)--([yshift=5pt]\tikzlastnode.north east)
node[draw=none,midway,above]{#1};
\end{pgfinterruptpath}}}
},
markht/.style={
append after command={
\pgfextra{%
\begin{pgfinterruptpath}
\draw[|<->|,>=latex]
([xshift=-5pt]\tikzlastnode.south west)--([xshift=-5pt]\tikzlastnode.north west)
node[draw=none,midway,rotate=90,above]{#1};
\end{pgfinterruptpath}}}
},
}
\begin{document}
\begin{tikzpicture}
\node(n1)[dim={4in}{4in},markht={4in}]{$\int e^x dx = e^x$};
\node(n2)[dim={2in}{.5in},markht={.5in},anchor=south west]at(n1.north west){$0=0$};
\node(n3)[dim={1in}{1.5in},anchor=south west]at(n2.south east){$A=\pi r^2$};
\node(n4)[dim={1in}{2in},markwd={1in},anchor=south east]at(n1.north east){$F=kx$};
\node(n5)[dim={1in}{.5in},markwd={1in},anchor=south east,yshift=-\pgflinewidth]at(n3.north east){$e=mc^2$};
\node(n6)[dim={2in}{1.5in},markwd={2in},markht={1.5in},anchor=south west,yshift=-\pgflinewidth]at(n2.north west){$y=mx+b$};
\end{tikzpicture}
\end{document}
输出
假设@StevenBSegletes 对您的意图的解释是正确的,那么这是 TikZ 的方式:)
代码
\documentclass[]{article}
\usepackage{tikz}
\tikzset{
a1dim/.style={minimum width=841,minimum height=594,draw,fill=white!100!purple},
a2dim/.style={minimum width=420,minimum height=595,draw,fill=white!90!purple},
a3dim/.style={minimum width=421,minimum height=297,draw,fill=white!80!purple},
a4dim/.style={minimum width=210,minimum height=298,draw,fill=white!70!purple},
a5dim/.style={minimum width=211,minimum height=148,draw,fill=white!60!purple},
a6dim/.style={minimum width=105,minimum height=150,draw,fill=white!50!purple},
a7dim/.style={minimum width=106,minimum height= 74,draw,fill=white!40!purple},
a8dim/.style={minimum width= 52,minimum height= 76,draw,fill=white!30!purple},
nn/.style={minimum width=54, minimum height=76,draw,fill=gray},
}
\begin{document}
\begin{tikzpicture}
\begin{scope}[transform shape,scale=.3]
\node(A1)[a1dim]{};
\node(A2)[a2dim,anchor=south east,at=(A1.north east)]{};
\node(A3)[a3dim,anchor=south west,at=(A1.north west)]{};
\node(A4)[a4dim,anchor=south east,at=(A3.north east)]{};
\node(A5)[a5dim,anchor=south west,at=(A3.north west)]{};
\node(A6)[a6dim,anchor=south east,at=(A5.north east)]{};
\node(A7)[a7dim,anchor=south west,at=(A5.north west)]{};
\node(A8)[a8dim,anchor=south east,at=(A7.north east)]{};
\node(nn)[nn,anchor=south west,at=(A7.north west)]{};
\end{scope}
\node at(A1){$e=mc^2$};
\node at(A2){$e=mc^2$};
\node at(A3){$e=mc^2$};
\node at(A4){$e=mc^2$};
\node at(A5){$e=mc^2$};
\node[rotate=90] at(A6){$e=mc^2$};
\node[font=\tiny] at(A7){$e=mc^2$};
\node[font=\tiny,rotate=-90] at(A8){$e=mc^2$};
\end{tikzpicture}
\end{document}
输出
答案2
这引入了\cbox
4 个用于创建元素的参数。这些参数包括宽度、高度、比例因子和数学表达式。然后\cbox
将各种元素插入到背景字段中(也是用 创建的\cbox
)。
\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\usepackage{graphicx}
\newcommand\cbox[4]{%
\fboxrule=1pt\fboxsep=-.5\fboxrule%
\fbox{\stackinset{c}{}{c}{}{\scalebox{#3}{$#4$}}{\rule{#1}{0pt}\rule{0pt}{#2}}}%
}
\begin{document}
\def\field{\cbox{4in}{6in}{1}{}}
\def\boxA{\cbox{2in}{1.5in}{1.7}{y=mx+b}}
\def\boxB{\cbox{1in}{0.5in}{1.1}{e=mc^2}}
\def\boxC{\cbox{1in}{2in}{1.4}{F=kx}}
\def\boxD{\cbox{1in}{1.5in}{1.2}{A=\pi r^2}}
\def\boxE{\cbox{2in}{0.5in}{2}{0 = 0}}
\def\boxF{\cbox{4in}{4in}{4}{\int e^x dx = e^x}}
\stackinset{l}{}{t}{}{\boxA}{%
\stackinset{l}{2in}{t}{}{\boxB}{%
\stackinset{r}{}{t}{}{\boxC}{%
\stackinset{r}{1in}{t}{0.5in}{\boxD}{%
\stackinset{l}{}{t}{1.5in}{\boxE}{%
\stackinset{l}{}{b}{}{\boxF}{%
\field%
}}}}}}
\end{document}
答案3
这看起来像是一件重复的事情,因此可以考虑一些(过度)简化的代码。
\documentclass[tikz,margin=10pt]{standalone}
\newcommand{\mynode}[5][none]{%
\node[draw,fill=#1,minimum width=2cm,minimum height=3cm,outer sep=0pt,anchor=north west] at
(0,0) (a) {};
\node[draw,fill=#2,minimum width=2cm,minimum height=3cm,outer sep=0pt,anchor=north west] at
(a.north east) {#4};
\node[draw,fill=#3,minimum width=4cm,minimum height=3cm,outer sep=0pt,anchor=north west] at
(a.south west) {#5};
}
%% syntax
%% \mynode[<color1>]{<color2>}{<color3>}{<text1}{<text2}
\begin{document}
\begin{tikzpicture}
\begin{scope}[scale=4,anchor=north west,transform shape]
\mynode{red!20}{white}{$e=mc^2$}{$e=mc^2$}
\end{scope}
\begin{scope}[scale=2,anchor=north west,transform shape]
\mynode{green!20}{blue!20}{$e=mc^2$}{$e=mc^2$}
\end{scope}
\begin{scope}[scale=1,anchor=north west,transform shape]
\mynode{green!20}{blue!20}{$e=mc^2$}{$e=mc^2$}
\end{scope}
\begin{scope}[scale=0.5,anchor=north west,transform shape]
\mynode{green!20}{blue!20}{$e=mc^2$}{$e=mc^2$}
\end{scope}
\end{tikzpicture}
\end{document}
答案4
愿 PSTricks 用户平安。这是 PSTricks 中的一个模板。
\documentclass[pstricks,border=1.61803398875cc,12pt]{standalone}
\usepackage{pst-eucl,siunitx}
\begin{document}
\begin{pspicture}[showgrid=false](9,7)
\pstGeonode[CurveType=polygon,PosAngle={-135,-90,135,-45,45,-45}]
(0,0){A}
(4,0){B}
(4,4){C}
(8,4){D}
(8,6){E}
(0,6){F}
\pcline[offset=12pt]{|*-|*}(F)(E)\naput[labelsep=5pt]{\SI{12}{\centi\meter}}
\pcline[offset=12pt]{|*-|*}(E)(D)\naput[labelsep=5pt,nrot=:U]{\SI{2}{\centi\meter}}
\end{pspicture}
\end{document}