# Tag Info

3

The barycentric coordinate system in Harish's answer provides a fairly general method; in this concrete case, however you can use the calc library (already loaded in your code) simply say \node[place] (E) at ( $(A)!0.5!(C)$ ) {E}; The complete code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning,calc} \begin{document} ...

3

You can use baricentric cs for such jobs. For details, see the pgfmanual, page 133, section 13.2.2. \documentclass{article} \usepackage{tikz} \usetikzlibrary{arrows, decorations.pathmorphing, backgrounds, positioning,fit,petri} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} [%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ...

6

The xyz coordinate system can be configured, by specifying xy canvas vectors for x, y, and z. The examples defines the style yzx with a different mapping for the coordinate components: \documentclass{article} \usepackage{tikz} \tikzstyle{yzx} = [ x={(-.385cm, -.385cm)}, y={(1cm, 0cm)}, z={(0cm, 1cm)}, ] \begin{document} ...

5

There are several syntax problems: \tikz inside environment tikzpicture. This probably causes the messed up bounding box. The pic is finished after {cube folding}, but options follow as ordinary text (invisible because of \nullfont) with \node commands over printing, because they are all called at the same position (outside the folding pic). numbered faces ...

0

Just as Alenanno's suggestion,use define color marco will resolve the color issue. \documentclass[border=2pt]{standalone} \usepackage{tikz} \usetikzlibrary{shapes} \definecolor{bottomcol}{RGB}{222,222,222} \begin{document} \tikzstyle{class}=[ rectangle, draw=black, text centered, anchor=north, text=black, text width=3cm, ...

3

I learned a bunch from figuring this out. So thanks for asking! Here’s the nearly-MWE I came up with for pgfplotset: \PassOptionsToPackage{svgnames}{xcolor} \documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8x]{inputenc} \usepackage{mathtools} \usepackage[Symbolsmallscale]{upgreek} \usepackage{textcomp} \usepackage{pgfplots} ...

4

For the commands, see the TikZ manual which covers the library and includes an extensive tutorial on this topic. To move a single node, you can set level distance for that node. But since the level distance just is the distance between parent and child, you cannot alter the latter without changing the former. The colour problem is caused by the fact that ...

20

You can use TikZ and matrix of math nodes: The code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix,arrows.meta,positioning} \definecolor{myyellow}{RGB}{240,217,1} \definecolor{mygreen}{RGB}{143,188,103} \definecolor{myred}{RGB}{234,38,40} \definecolor{myblue}{RGB}{53,101,167} \begin{document} \begin{tikzpicture}[ mymatrix/.style={ ...

5

Here's one possibility using pgfplots; the spiral is drawn first and used to draw the truncated code: The code: \documentclass[dvipsnames,border=5pt]{standalone} \usepackage{pgfplots} \usetikzlibrary{calc} \pgfplotsset{compat=newest} \colorlet{myblue}{blue!30} \def\Pointi{42.67} \def\Pointii{12.6} \begin{document} \begin{tikzpicture} \begin{axis}[ ...

2

Name the plot and a line along the y-axis \addplot[name path=plot,thick,samples=100,domain= 0:3.5] {2.6913*ln(x)}; \path[name path=yaxis](current axis.below origin)-- (current axis.above origin); Then you can use \addplot[gray!30] fill between[ of=yaxis and plot,reverse=false, soft clip={domain y = .5:2.5}, ]; to fill the area between the plot and ...

2

Almost the same approach as suggested Harish Kumar: \documentclass[border=3mm, tikz, prewiev]{standalone} \usetikzlibrary{calc,positioning} \begin{document} \newlength{\nodedist} \setlength{\nodedist}{5cm} \begin{tikzpicture}[ node distance = \nodedist, draw = red, mynode/.style = {shape=rectangle, ...

4

You can use a scope and then pass the option every to/.style={append after command={[draw=red]}} to it like \begin{scope}[every to/.style={append after command={[draw=red]}}] \draw[->] (controller.west) to[bend left] node[arrow label] {Change state} (model.south); \draw[->] (controller.east) to[bend right] node[arrow label] {Update display} ...

3

You have end of line spaces. To remove them add few % marks at the end of lines like I did. \documentclass{article} \usepackage{tikz} \usetikzlibrary{shapes.geometric} \newcommand{\yellowstar}{% \tikzstyle{scorestars}=[star, star points=5, star point ratio=2.5, draw,inner sep=1.3pt,anchor=outer point 3]% \begin{tikzpicture}[baseline] \draw (0,0) ...

2

I am the author of the template Gabriel uses, and I do make use of overlay and remember picture for the cover page. But I'm pretty sure that the real solution to this problem is to make use of axis cs when specying the nodal points in the plot axis c.s. The pgfplots gallery show multiple uses of this. \node[...] at (axis cs:0.18,0.74,0.08) {...}; (I ...

3

You can use perpendicular coordinate system at (t2|-d1) in \node at (t2|-d1) {Desc2}; (t2|-d1) means - x coordinate same as t2 and y coordinate same as d1. So if (x1,y1) are coordinates of t2 and (x2,y2) are coordinates of d1 then (t2|-d1) (or equivalently {d1-|t2)) is equal to (x1,y2). For more details, read pgfmanual, page 137, section 13.3.1. ...

1

I have had a similar issue since updating the pgf package to 3.0.1. Any connector usage in tikz-uml causes the pgfmath problem. I have written to Mr. Kielbasiewicz and await his reply as I am not savvy enough to unravel the mystery of this one. Meanwhile, reverting to an earlier pgf version has solved the problem for me.

3

You can select the baseline for the tikzpicture; for example, using baseline=(current bounding box.north) as option you get The code: \documentclass[12pt,leqno]{article} \usepackage{amsmath, amsfonts, amssymb,amsthm} \usepackage[margin=1 in]{geometry} %margins \usepackage{tikz} %Vector Drawing and Graphs \usepackage{pgfplots} \usepackage{enumitem} ...

4

TikZ 3.0.0 has a babel library intended for compatibility with the babel package, that fixes catcodes within tikzpicture, and seems to also solve the onlyamsmath compatibility issue for me. Note: as cfr points out, this does of course still disable onlyamsmath checking within TikZ pictures \documentclass{article} \usepackage[all,warning]{onlyamsmath} ...

12

One option using a style and append after command to add the dashed lines to the node; since the solution uses \path ... node ...; you can do all operations on nodes (use the standard available keys, name them and have access to their anchors to draw elements): \documentclass{article} \usepackage{tikz} \tikzset{ keep name/.style={ prefix after ...

14

This is done via transparency groups and relies mostly on PDF rendering so sometimes it might go awry. Here is an example that within the scope everything is as usual overprinting with respect to drawing order but the overall result is transparent with respect to the background. \documentclass[tikz]{standalone} \usetikzlibrary{patterns} \begin{document} ...

2

Another approach, here nodes are named 0,1,... \documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning,shapes} \newcounter{i} \setcounter{i}{0} \tikzset{ eq/.style={minimum width=3cm,rectangle,name=\thei}, bubble/.style={draw,help lines,ellipse}} \begin{document} \def\step#1#2{% \node[bubble] (left) [below left=of \thei] ...

0

Add complete MWE the next time and add \centering within the figure environment CODE: \documentclass{article} \usepackage{tikz} \usepackage{mathtools} \begin{document} \begin{figure} \centering \begin{tikzpicture} \begin{scope}[thick,font=\scriptsize] % Axes: % Are simply drawn using line with the -> option to make them ...

1

You can use it as follows: Don't use macro names starting with \the. That is a special case for TeX and might lead to mistakes that are very difficult to debug. \documentclass{article} \usepackage{pgfplotstable} \begin{document} \begin{tikzpicture} \pgfplotstableread[col sep=comma,header=false]{ ...

2

I found tikz-cd surprisingly suited in this case. \documentclass[tikz,border=9]{standalone} \usepackage{tikz-cd} \usetikzlibrary{shapes.geometric} \begin{document} %%%%%%%%%%%%%%%%%%%% What YOU would like to automate %%%%%%%%%%%%%%%%%%%% \begin{tikzcd}[row sep=30] ax^2+bx+c=0 \dar[bend ...

3

Slightly modified (simplyfied) @Sergej solution: \documentclass[border=2mm, tikz, preview]{standalone} \usetikzlibrary{positioning,chains} \begin{document} \begin{tikzpicture}[ node distance=15mm and 10mm, start chain=going below, mynode/.style = { draw, rectangle, align=center, text width=5cm, ...

6

Here is a possible solution using the tikz positioning and chains libraries: \documentclass[tikz,border=10pt]{standalone} \usetikzlibrary{positioning,chains} \begin{document} \tikzset{ mynode/.style={ draw, rectangle, align=center, text width=5cm, font=\small, inner sep=3ex}, mylabel/.style={ draw, rectangle, align=center, ...

0

Assuming the use of nodes combined with the minimum width, minimum height and minimum size options to generate squares and/or rectangles, another possible solution would be to adjust the provided sizes by subtracting from them \pgflinewidth (there are two drawn lines in each direction and only half of each drawn line is drawn outside the shape, giving us ...

1

To clarify, the lower part is also a shading pattern, just more compressed, but I was able to use what you'd given me and alter it to do the job. This is the final version made using Gonzalo Medina's answer: \begin{figure}[!ht] \begin{minipage}{0.5\linewidth} \begin{tikzpicture} \node[inner sep = 0] (a) at (-4,0) ...

5

Taking advantage of what you've already done, but changing a little the coordinates; for the lower part I used a custom pattern which is a variation of north east lines, but allowing you to specify the separation between the lines, their width and color: \documentclass{article} \usepackage{tikz} \usetikzlibrary{patterns} % defining the new dimensions and ...

2

It isn't entirely clear which line you are trying to draw: a line from the left to right of the page? a diagonal? (which one?) This example uses colours to distinguish four possibilities: \documentclass{article} \usepackage{tikz} \begin{document} \thispagestyle{empty} \begin{tikzpicture}[remember picture,overlay] \coordinate (A) at (current ...

5

This works just fine. You had the coordinates wrong and a missing ;. I've removed a few packages that are not relevant for the mwe \documentclass{article} \usepackage{tikz,xcolor} \begin{document} \thispagestyle{empty} \begin{tikzpicture}[remember picture,overlay] \coordinate (A) at (current page.north west); \coordinate (B) at (current page.south ...

4

It's a problem of mixing units. Using simply ($(Q) + ({0.5*(\n1+\n2+180)}:{-0.5-5pt})$) PGF assumes unit is pt so it simply moves you -5.5pt away from Q (similarly, ($(Q) + ({0.5*(\n1+\n2+180)}:{-0.5+5pt})$) moves you just 4.5pt away from Q. What you need is to specify cm for the 0.5 \draw[draw=green,fill] let \p1=($(Q)-(R)$), \n1={atan(\y1/\x1)}, ...

2

If you have to set existing TikZ keys with the parser then you can use style args. If you need a custom code to be executed then you can also use code args and proceed from there. For the specific example, a possible way to do it: \tikzset{angles/.style args={#1,#2}{start angle=#1, end angle=#2}} \def\MyCircle[#1]#2{\draw #2 arc [#1];} ...

4

Using the positioning library to place the nodes and some styles, your code can be simplified: \documentclass[border=4pt]{standalone} \usepackage{enumitem} \usepackage{tikz} \usetikzlibrary{positioning} \setlist[itemize,1]{leftmargin=*,topsep=0pt} \begin{document} \begin{tikzpicture}[ mybox/.style={ draw, text width=5.7cm, anchor=north }, ...

4

Without TikZ. Still far from perfect though. \documentclass{memoir} \usepackage[paperwidth=10.5cm,paperheight=15.5cm,headheight=0.5in]{geometry} \usepackage{xcolor} \usepackage[explicit]{titlesec} \definecolor{sec}{HTML}{DD5C14} \definecolor{band}{HTML}{EE9C52} \titleformat{\section}[hang]{\sffamily\Huge\bfseries}{}{0.5ex}% ...

5

Do you want simple foreachs for everything? The same as in your code can be done with % arara: pdflatex \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw[step=1cm,black,thin] (0,0) grid (5,5); \foreach \xtick in {0,...,5} {\pgfmathsetmacro\result{\xtick * .2} \node at (\xtick,-0.5) ...

0

A solution non generalized with array, xcolor. The problem that i have encountered is centering "Bar1" any one has a best way of centering is invited to correct it. Code \documentclass[margin=2mm]{standalone} \usepackage{array} \usepackage[table]{xcolor} \newlength{\len} \settowidth{\len}{Bar1} \def\mylen{\dimexpr -0.2\len -2\tabcolsep} ...

3

To draw diamonds, you have to include the shapes tikz library (and for arrows the arrows tikz library) in the preamble: \documentclass{article} \usepackage{tikz} \usetikzlibrary{trees} \usepackage[active,tightpage]{preview}% just for showing image \PreviewEnvironment{tikzpicture} \usetikzlibrary{shapes,arrows} \setlength\PreviewBorder{5pt}% ...

3

As Claudio Fiandrino said, you need to load the shapes (or shapes.geometric) tikzlibrary, too, in order to make diamond work. When I tried your code, the setting every node./style={...} gave some problems, because it was overriding the decisionstyle (and all the other styles): Since you have defined a style for each node, I'd suggest you to use them: ...

10

This is straightforward using TikZ: The code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix,calc,backgrounds} \definecolor{mybrown}{RGB}{33,34,28} \definecolor{myyellow}{RGB}{242,226,149} \definecolor{mygreen}{RGB}{176,232,145} \definecolor{myblue}{RGB}{61,139,189} \definecolor{myorange}{RGB}{245,156,74} ...

1

Nesting tikzpictures generally spells trouble. Sometimes it works, but you can't complain they didn't warn you if it breaks. Therefore, it should be considered only as a last resort. In this case, the code is safer and simpler if the tikzmark library is used to support the \subnode{}{} syntax. The first argument is the name. The second the content. Note ...

4

Nothing special here, since you have access to the anchors for the nodes in the matrix, so you simply need \draw[red,decorate,decoration={brace,mirror,raise=-2pt}] ([xshift=3pt]a-2-2.south west) -- ([xshift=-5pt]a-2-3.south east); or \draw[red,decorate,decoration={brace,mirror,raise=-2pt}] ([xshift=3pt]a-2-2.south west) -- ([xshift=-4pt]{a-2-3.south ...

1

Although I second egreg's suggestion about using tikz-cd, here's how to do it with your current settings. You have two options: Enclose in braces changes in arrow specification to keep them local. Add [-stealth] before the edge to restore the arrow type. I illustrate both options below. \documentclass{article} \usepackage{tikz} ...

2

I suggest using tikz-cd which has a much simpler syntax: \documentclass{article} \usepackage{tikz-cd} \begin{document} \begin{tikzcd} M,\phi,\xi,\eta,g \arrow[r,hook] \arrow[d] & C(M),\omega,\bar{g},\bar{\phi}\\ Z,\Omega,h,J \end{tikzcd} \end{document} If you want stealth arrows, you can set them globally: \documentclass{article} ...

1

You can use the every picture style: \documentclass{article} \usepackage{tikz} \tikzset{ every picture/.append style={ line join=round, line cap=round, } } \begin{document} \begin{tikzpicture}[line width=10pt] \draw (0,0) -- (0,3) -- (3,0); \end{tikzpicture} \end{document} As for the miter limit, if you try something like \tikzset{ ...

1

Box the listing before using it in the argument for \node: \documentclass{beamer} \usepackage{tikz} \usepackage{listings} \newcommand{\rednode}[1]{ \node[draw=red]{#1}; } \newsavebox\mybox \begin{document} \begin{lrbox}{\mybox} \begin{lstlisting} int main() { printf("Hello World\n"); } \end{lstlisting} \end{lrbox} \begin{frame}[fragile] ...

1

The syntax in the code from TeXample is wrong (perhaps there was a change in the syntax sometime after the code was posted there and it has not been updated?). In any case, \Vertex has to be used with braces, as in \Vertex{P} and \NOEA (and similar) receives a first argument inside parentheses and the second one inside braces, as in \NOEA(P){B}. ...

2

Possibly overkill, but you could adapt Morley's theorem, and use trilinear coordinates that form the equilateral triangle whose vertices can be used to describe the trisectors. Unfortunately, the conversion from trilinear coordinates to tkzEuclide's barycentric coordinate system involves some fiddling. \documentclass[tikz,border=5]{standalone} ...

1

\x takes the string length as last value: \StrLen{#1}[\mylen]; \foreach \x in {1,...,\mylen} { Then \second \pgfmathtruncatemacro{\second}{\x+1}; is larger than the string length, but \StrChar{#1}{\y}[\numB]; \y is empty now, because #1 does not provide any digits after the string end and the empty \numB is invalid in the multiplication: ...

3

To trisect an angle, try something like this: \begin{tikzpicture}[scale=1] \tkzDefPoint(6,0){A} \tkzDefPoint(0,1){B} \tkzDefPoint(1,4){C} \tkzDrawSegments(A,B B,C) % Get the angle and define two new points that lie on the trisectors. \tkzFindAngle(A,B,C) \tkzGetAngle{at} \tkzDefPointBy[rotation=center B angle 1*\at/3](A) \tkzGetPoint{T1} ...

Top 50 recent answers are included