How to create a mindmap in Latex with hexagonal shapes? - latex

I'm busting my head on creating a mindmap in LaTex/TikZ with nodes being displayed not as boxes, circles or ellipses. Is there a way to create a mindmap using hexagons as children? The children ought to be connected to the corners. Parents and children should contain a short text
I've tried using the shapes package.
Thank you in advance,
Pjotr

Altering the shapes of the child nodes is easy, you could simply use regular polygon, regular polygon sides=6 from the shapes library. However altering the connections between the root node and the hexagones is more difficult (at least for us mere mortals, tikz wizards can do it, see https://tex.stackexchange.com/a/514772/36296).
Instead you could emulate a mindmap with normal nodes:
\documentclass[margin=0.3cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\def\nchilds{5}
\node[fill=blue,text=white,circle,minimum size=3cm] at (0,0) (root) {Root};
\foreach \x [count=\xi] in {test1, test2, test3, test4, test5}{
\shade[left color=red,right color=blue,shading angle={(360/\nchilds*\xi)-90}]
({(360/\nchilds*\xi)+3}:3.2cm) to [in=160,out=10,relative]
({(360/\nchilds*\xi)+10}:1.45cm) -- ({(360/\nchilds*\xi)-10}:1.45cm) to [in=170,out=20,relative] ({(360/\nchilds*\xi)-3}:3.2cm);
\node[regular polygon, regular polygon sides=6,fill=red,minimum width=2cm,shape border uses incircle,shape border rotate=(360/\nchilds*\xi)] at (360/\nchilds*\xi:4cm) {\x};
}
\end{tikzpicture}
\end{document}
(many thanks to #marmot for the hint about shape border rotate!)

Related

Overlaying off-margin figure over another on Latex using Tikz

I was hoping anyone could help me with this. I am working with Latex and the Tikz package (I'm a new user on both) on a document cover using 2 figures so it looks like this:
That is, the background image leaves a thin margin on all sides, and the logo falls off-margin to the right and bottom. So, I enter the code overlaying the the logo over the background using Tikz, and as soon as I edit the coordinates to get the logo to go off-margin either on the right or bottom, the background image starts moving to the left and top until it sticks to the opposing borders of the page, like this:
My question is, is there a way to have the superimposing image to fall off the margins while keeping the background image properly centered?
Here is the code I'm using:
\usepackage{mwe,tikz}
\begin{figure}
\begin{tikzpicture}[
every node/.style={anchor=south west,inner sep=20pt},
x=1mm, y=1mm,
]
\node (fig1) at (0,0)
{\includegraphics[scale=0.2]{Images/Background.jpg}};
\node (fig2) at (124,-23)
{\includegraphics[scale=1.5]{Images/Logo.png}};
\end{tikzpicture}
\end{figure}
I first tried using the Overpic package instead, but I found it to be rather limited (or I couldn't figure it out well enough probably). I then tried using \centering and other horizontal and vertical centering techniques in combination with Tikz, but to no avail.
A figure environment is a floating objects, which allows latex to find a good location within the text flow. If you want an image at a very specific position, like a title page, you shouldn't use a figure environment
using the overlay option will make sure that the actual size of the tikzpicture does not influence the positioning and thus a cutoff logo won't influence the rest of the page
I also suggest the remember picture option which allows you to position your nodes with respect to the page. This way you can place the big picture in the centre of the page and the smaller picture at the lower right corner (shift it around with the xshift and yshift keys)
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\includegraphics[width=.9\paperwidth,height=.9\paperheight]{example-image-10x16}};
\node at ([xshift=-2cm,yshift=1cm]current page.south east) {\includegraphics[width=15cm]{example-image-duck}};
\end{tikzpicture}
\end{document}

LaTeX hexagonal chains

I am using LaTeX for research with hexagonal chains and would like to know some ways to create the a horizontal hexagonal chain. So far I only have some going vertically; I have used code I received on here under a previous question but haven't figured out how to rotate the vertical chain of hexagons to make it horizontal.
Is it possible to use chemfig or tikz to create a chain similar to either of these?
Here is an example with the chemfig package
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\begin{figure}
\centering
\chemfig{*6(--*6(--*6(-----)---)----)}
\caption{Chain of 3 hexagons}
\end{figure}
\end{document}
And the corresponding output

How can i get a symbol, produced by putting one character on the surface on the other, in LaTeX?

I need to type in my document, but I can't find the proper way to do it. It looks like it was made by combining $\Diamond$ and $\Box$ somehow. So how can i get it?
If you can't find the symbol available somewhere, I would think using tikz would be an easy solution. Small tikz pictures can be inlined or defined as a command. The symbol can be created as contents of overlapping nodes, the node shapes or a handmade tikz path. The following code shows some examples:
\documentclass{article}%
\usepackage{tikz}%
\usepackage{amssymb}
\usetikzlibrary{shapes,math}
\newcommand{\myawesomesymbol}[1]{\tikz[baseline=-1mm]{\node[diamond, draw, inner sep=#1]{}; \node[draw, inner sep=#1]{};}}
\newcommand{\mythicksymbol}[1]{\tikz[baseline=-1mm]{\node[thick, diamond, draw, inner sep=#1]{}; \node[thick, draw, inner sep=#1]{};}}
\newcommand{\myhandmadesymbol}[1]{\tikz[baseline=-1mm]{
\draw[] (-#1,-#1) -- (#1,-#1) -- (#1,#1) -- (-#1,#1) -- (-#1,-#1);
\draw[] (-2.1*#1, 0) -- (0,2.1*#1) -- (2.1*#1,0) -- (0, -2.1*#1)-- (-2.1*#1,0);}}
\begin{document}
This is some sentence with this symbol \tikz[baseline=-1mm]{\node[diamond, draw]{}; \node[draw]{};} in the text.
This one \myawesomesymbol{.7mm} is smaller and as a command and there is a larger one: \myawesomesymbol{3mm}, or scaling with the font size: {\tiny tiny \myawesomesymbol{.5ex}}, {\small small \myawesomesymbol{.5ex}}, Large {\Large \myawesomesymbol{.5ex}}.
Maybe thick: \mythicksymbol{1.5mm}.
Using tikz, it is also possible to overlay math symbols as suggested in the question: \tikz[baseline=-1mm]{\node[]{\Huge$\diamond$}; \node[]{\tiny$\Box$};}, however, the spacing is not perfect.
And last, in case the little overlapping corners are a concern, it is still possible drawing it by hand: small \myhandmadesymbol{.1}, larger \myhandmadesymbol{.2}, scaling with font \myhandmadesymbol{.5ex}.
\end{document}
Output:

Improving outputs in tikz package

$F_1(g)=\left\{
\begin{tikzpicture}
\node[shape=circle,draw=black] (A) {$b^1_0$};
\end{tikzpicture} \right\}$
Doing this code, I have an output like this Output
And I'd like something more centered into the brackets, like if I'm still writing instead of drawing.
You have to change the baseline of the picture to be at its center, then align that baseline to the vertical center of the text. This can be done with the option [baseline={([yshift=-.8ex]current bounding box.center)}]. I added it to the example code you gave, and also changed the inner sep of the circle to 0pt. Let me know if that works for you.
$F_1(g)=\left\{
\begin{tikzpicture}[baseline={([yshift=-.8ex]current bounding box.center)}]
\node[shape=circle,draw=black, inner sep=0pt] (A) {$b^1_0$};
\end{tikzpicture} \right\}$
\end{document}

tikz explain/annotate equation in LaTeX using straight arrows with right angles

Thanks to this excellent answer, I can get an equation as in this figure: with bent arrows. But what I really want is as in this figure: with right-angled arrows.
To simply write the code, you may start by modifying the code from here.
Update: I've turned equation annotation into a LaTeX annotate-equations package (also on CTAN), which you might find useful.
Adapting Mike Renfro's answer
to straight edges is fairly straightforward: all I did was change from
\begin{tikzpicture}[overlay]
\path[->]<1-> (nCPP) edge [bend left] (tCPP);
\path[->]<2-> (nL) edge [bend left] (tL);
\path[->]<3-> (nPPP) edge [out=0, in=0] (tPPP);
\path[->]<4-> (nPP) edge [out=0, in=-90] (tPP);
\end{tikzpicture}
to
\begin{tikzpicture}[overlay,->]
\draw<1-> (nCPP) -| (tCPP);
\draw<2-> (nL) -| (tL);
\draw<3-> (nPPP) -| (tPPP);
\draw<4-> (nPP) -| (tPP);
\end{tikzpicture}
Changes explained:
replaced the edge and bend options with -| (there's also |- to bend at right angles the other way)
replaced \path with \draw to get the lines actually drawn
moved [->] into the tikzpicture environment options because for some reason it didn't work as \draw[->].
I've also set aspectratio=169 so there's enough space for the arrow for Predictor Prior Probability (it's also possible to work around that, but more hacky). This is what it looks like:

Resources