我对 tikz 等图形软件包没有太多经验,但我决定尝试使用 LaTeX 而不是 GIMP 等来创建一些东西。
但是因为过一段时间我可能会更改图片中的某些文本,所以我决定最好在 LaTeX 中更改它,而不是使用某些外部图形编辑器,因此我尝试使用 forest 包、tcolorbox 包和 tikz 包在 LaTeX 中重现图片。
这就是我想出的:
我正在创建这个图片作为子文件。
这是我的主文件中的包定义:
\documentclass{article}
\usepackage{forest}
\usepackage[most]{tcolorbox}
\usepackage{tikz}
\newtcolorbox{note}[1][]{%
enhanced jigsaw,
borderline north={2pt}{0pt}{cyan},
sharp corners,
boxrule=0pt,
fonttitle={\large\bfseries},
colback={gray},
#1
}
这是子文件:
\documentclass[Main.tex]{subfiles}
\begin{document}
\begin{note}
\begin{center}
\color{white}Some text\\
\vspace*{0.2cm}
\includegraphics[width=0.9cm,height=0.3cm,keepaspectratio]{output-arrows.png}\\
\vspace*{0.2cm}
\begin{tikzpicture}
\draw [fill=cyan,draw=cyan, ultra thick] (0,0) circle (1.0cm)
node {Text};
\end{tikzpicture}
\end{center}
\begin{center}
\begin{forest}
for tree={
edge path={
\noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(0,0pt) -| (.child anchor)\forestoption{edge label};
},
align=center,
parent anchor=west,
child anchor=north
}
[, phantom, for children={fit=band}
[
[\color{white}Some text\\\color{white}and some other text
]
[\color{white}Some text\\\color{white}text
]
[\color{white}Some text\\\color{white}text
]
[\color{white}Some text\\\color{white}some text\\\color{white}some text
]
[\color{white}Some text\\\color{white}text
]
]
]
\end{forest}
\end{center}
\end{note}
\end{document}
不幸的是,我无法完善结果,所以它看起来就像上面的那个。
我需要纠正树形图(没有箭头并且不以黑线而是白线为中心),然后我需要将框的宽度更改为整个页面的宽度,并更改高度以使其看起来与上面的类似。
当我尝试完善它时,不幸的是我总是出错,你能帮助我实现我需要的吗?谢谢
答案1
我不太了解这个子文件,但我无法让你的文件组合工作。无论如何,尽管我喜欢森林,但我会选择一个稍微不同的,Ti钾Z “唯一”路径来实现输出。chains
如果读过 pgfmanual v3.1.5b 的第 604 页,可以以一些有趣的方式使用它,下面是一个例子。
\documentclass{article}
\renewcommand*\familydefault{\sfdefault}
\usepackage[most]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,chains}
\newtcolorbox{note}[1][]{%
enhanced jigsaw,
borderline north={2pt}{0pt}{cyan},
sharp corners,
boxrule=0pt,
fonttitle={\large\bfseries},
colback={gray},
#1
}
\begin{document}
\section*{\textcolor{blue!40!black}{Some text some text}}
\begin{note}
\centering
\begin{tikzpicture}[text=white]
\begin{scope}[local bounding box=leaves,
start chain=A going {right=of \tikzchainprevious.south east},
nodes={on chain,anchor=south,
align=center,execute at end node={\global\let\mynumnodes\tikzchaincount}}]
\node{Some text\\and some other text};
\node{Some text\\text};
\node{Some text\\text};
\node{Some text\\some text\\some text};
\node{Some text\\text};
\end{scope}
\foreach \X in {1,...,\mynumnodes}
{\draw[line width=2pt,Triangle-,white] (A-\X|-leaves.north) -- ++ (0,2em) coordinate (t-\X);}
\draw[line cap=rect,line width=2pt,white] (t-1) -- (t-\mynumnodes)
node[midway,above=2em,circle,fill=cyan!50,node font=\Large\bfseries,minimum size=9em] (c)
{Text};
\node[above=4em of c,node font=\large\bfseries](t){text};
\path[line width=2pt,Triangle-,white,shorten >=2ex,shorten <=2ex]
([xshift=-1em]t.south) edge ([xshift=-1em]c.north)
([xshift=1em]c.north) edge ([xshift=1em]t.south);
\end{tikzpicture}
\end{note}
\end{document}
附录:为了tikzpicture
在垂直方向上扩展边界框,您可以添加
\path (current bounding box.north) + (0,1);
\path (current bounding box.south) + (0,-1);
或者,等价地,
\path (current bounding box.north) + (0,1) (current bounding box.south) + (0,-1);
完整代码和结果:
\documentclass{article}
\renewcommand*\familydefault{\sfdefault}
\usepackage[most]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,chains}
\newtcolorbox{note}[1][]{%
enhanced jigsaw,
borderline north={2pt}{0pt}{cyan},
sharp corners,
boxrule=0pt,
fonttitle={\large\bfseries},
colback={gray},
#1
}
\begin{document}
\section*{\textcolor{blue!40!black}{Some text some text}}
\begin{note}
\centering
\begin{tikzpicture}[text=white]
\begin{scope}[local bounding box=leaves,
start chain=A going {right=of \tikzchainprevious.south east},
nodes={on chain,anchor=south,
align=center,execute at end node={\global\let\mynumnodes\tikzchaincount}}]
\node{Some text\\and some other text};
\node{Some text\\text};
\node{Some text\\text};
\node{Some text\\some text\\some text};
\node{Some text\\text};
\end{scope}
\foreach \X in {1,...,\mynumnodes}
{\draw[line width=2pt,Triangle-,white] (A-\X|-leaves.north) -- ++ (0,2em) coordinate (t-\X);}
\draw[line cap=rect,line width=2pt,white] (t-1) -- (t-\mynumnodes)
node[midway,above=2em,circle,fill=cyan!50,node font=\Large\bfseries,minimum size=9em] (c)
{Text};
\node[above=4em of c,node font=\large\bfseries](t){text};
\path[line width=2pt,Triangle-,white,shorten >=2ex,shorten <=2ex]
([xshift=-1em]t.south) edge ([xshift=-1em]c.north)
([xshift=1em]c.north) edge ([xshift=1em]t.south);
% enlarge bounding box in positive and negative y directions
\path (current bounding box.north) + (0,1);
\path (current bounding box.south) + (0,-1);
% equivalent way of enlarging it
% \path (current bounding box.north) + (0,1) (current bounding box.south) + (0,-1);
\end{tikzpicture}
\end{note}
\end{document}