If you want it to be more right, then you should specify below right
and not below left
:
\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[domain=0:2*pi]
\draw[xstep=pi/4, ystep=0.5, dashed, color=gray] (-0.1,-1.6) grid (2*pi,1.6);
\draw[->] (-0.2,0) -- (7,0) node[right] {$t$};
\draw[->] (0,-2) -- (0,2) node[above] {$i(t)$};
\node[below left](0,0){$0$};
\draw[color=blue, smooth] plot (\x,{sin(\x r)}) node[below right] {$i(t)$};
\node[below right] at (2,2) {$i(t) = I_0\sin\omega t$};
\end{tikzpicture}
\end{document}
You can find more information on positioning nodes in the pgfmanual, section 16.5.
You can add a label and then shift it to inside like
label={[shift={(-3ex,3ex)}]south east:#1}
in the definition of bigbox
:
bigbox/.style={draw, inner sep=20pt,label={[shift={(-3ex,3ex)}]south east:#1}}
and then say bigbox=D
in
\node[bigbox=D, fit=(A)(B)(C)] (D) {};
Full code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows, decorations.markings,shapes,arrows,fit}
\tikzset{box/.style={draw, minimum size=2em, text width=4.5em, text centered},
bigbox/.style={draw, inner sep=20pt,label={[shift={(-3ex,3ex)}]south east:#1}}
}
\begin{document}
\begin{tikzpicture}
\node[box] (A) at ( -2,1) {$A$};
\node[box] (B) at ( 1,1) {$B$};
\node[box] (C) at ( 4,1) {$C$};
\node[bigbox=D, fit=(A)(B)(C),] (D) {};
\end{tikzpicture}
\end{document}
![enter image description here](https://i.stack.imgur.com/0WkAC.png)
Edit
Response to the comments:
Here a label
is drawn for the node with label={[shift={(-3ex,3ex)}]south east:#1}
which is shift
ed and #1
is the content of the label. For more, refer to pgfmanual
. As for the complex content, I hope the following is complex enough :-)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows, decorations.markings,shapes,arrows,fit}
\tikzset{box/.style={draw, minimum size=2em, text width=4.5em, text centered},
bigbox/.style={draw, inner sep=20pt,label={[align=right,shift={(-1.5ex,3ex)}]south east:\llap{#1}}}
}
\begin{document}
\begin{tikzpicture}
\node[box] (A) at ( -2,1) {$A$};
\node[box] (B) at ( 1,1) {$B$};
\node[box] (C) at ( 4,1) {$C$};
\node[bigbox={$x^n + y^n = z^n$},label=south east:D, fit=(A)(B)(C)] (D) {};
\end{tikzpicture}
\end{document}
![enter image description here](https://i.stack.imgur.com/gSJ6k.png)
Best Answer
A
sloppypar
will momentarily allow you to overcome the problem. This problem arises for any oversized box that wants to be typeset at the end of a line.The
sloppypar
feature (or\sloppy
for the whole document) changes TeX's penalties to give more emphasis to avoiding margin overruns, at the expense of grossly wide interword spaces. There is no "free lunch."