$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}
Related
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}
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!)
How to position the smaller nested box, so it appeared in the top right corner (see image below)?
Here is my current, wrong implementation:
\newcommand\TBox[3][]{%
\tikz\node[draw,ultra thick,text width=#2,align=left,#1] {#3};}
\TBox{14cm}{%
\TBox{10cm}{xxx \vspace{9cm}} \TBox{3cm} \\
}
It would be better to place all your boxes in a single tikzpicture, because right now you are nesting them which is in general not a good idea.
To come back to your original question, you can use baseline=(current bounding box.north) to top align the boxes:
\documentclass{article}
\usepackage{tikz}
\newcommand\TBox[3][]{%
\tikz\node[draw,ultra thick,text width=#2,align=left,#1,baseline=(current bounding box.north)] {#3};}
\begin{document}
\TBox{14cm}{%
\TBox{10cm}{xxx \vspace{9cm}} \TBox{3cm} \\
}
\end{document}
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:
If you take a look at http://www.texample.net/tikz/examples/boxes-with-text-and-math/ the boxes there are with rounded corners. In the examples, both the box itself and the title is a box. I want the title box to not have the bottom corners rounded.
On page 120 in the manual, there is a description of how to draw with and without rounded corners. However, I want to use this in a fancytitle. It looks a bit silly to have the fancytitle as a box where all corners are rounded when it is as wide as the box itself.
\begin{tikzpicture}[baseline=-2cm]
\node [mybox] (box){
\begin{minipage}[t!]{0.50\textwidth}
Help, I'm a box
\end{minipage}
};
\node[fancytitle, text width=0.5423\textwidth, text centered, rounded corners] at (box.north) {Help, I'm a title};
\end{tikzpicture}
The style I use is this
\tikzstyle{mybox} = [draw=red, fill=blue!20, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
\tikzstyle{fancytitle} = [fill=red, text=white]
Possibly the most simple way to achieve the effect (with out solving the problem) is as follows.
Add name=title to the title node.
then draw a line along the bottom of the title node.
\draw [draw=red,line width=2pt] (title.south west) -- (title.south east);
This gives two little spots where the line over shoots, to fix this you can add.
\usetikzlibrary{calc}
And move make the line 1 point shorter at each end, and up a bit.
\draw [draw=red,line width=2pt] ($(title.south west)+(+1pt,+1pt)$) -- ($(title.south east)+(-1pt,+1pt)$) ;