# Tag Info

## New answers tagged tikz-pgf

3

The same plot command can be used to construct a path for the filled area: \fill [gray, domain=-2:2, variable=\x] (-2, 0) -- plot ({\x}, {\x*\x}) -- (2, 0) -- cycle; Full example: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw[very thin, gray!30, step=1 cm](-4.9,-3.9) grid (4.9,3.9); \fill [gray, ...

1

Setting concept color=green as a node option does not effect the connection to the first level children. Use it as an option of the tikzpicture. \begin{tikzpicture}[mindmap,concept color=green] You could place the Red Node 2 as an extra concept of level 2 in the middle of the Red Node 1 and Red Node 3. If you name the node the children will automatically ...

2

The current (3.0.0) TikZ manual has this to say: [\label in the externalized graphics which is referenced in the main document] is realized automatically by the external library. In detail, a \label inside of an externalized graphics causes the external library to generate separate auxiliary files for every external image. These files are called ...

6

When I searched for a package to do this, I didn't find anything which did not require some kind of hack. At the time, I hacked qtree. Now, I would probably use forest: \documentclass[tikz,border=5pt]{standalone} \usepackage{forest} \begin{document} \forestset{ ass/.append style={ before computing xy={l=\baselineskip}, no edge }, } ...

0

A possible solution with pics. It's difficult to use pic-anchors for positioning (Anchoring TiKZ pics) but they serve as reference points for drawing links between them. \documentclass[tikz,border=2mm]{standalone} \usetikzlibrary{positioning,circuits.logic.US, fit} \tikzset{ mycircuit/.pic={ \begin{scope}[circuit logic US] \node[gray, ...

4

In a nutshell, if you pass more than a file name (a path) to pgfdeclareimage, pdflatex looks just there. Otherwise, it looks for it in the complete search path, which traditionally is specified in the TEXINPUTS environment variable. So a simple solution would be to add ./art to TEXINPUTS and then just use the file name in pdfdeclareimage. However, as this ...

1

There is a known but with pgfplots version 1.12, the forget plot option and LuaTeX. This is fixed in version 1.12.1 which has been released to CTAN and will presumable be available in TeX Live 2015 and MiKTeX 2.9 in due course.

3

Change your \drawme as \newcommand{\drawme}[3]{ \draw[*->,rounded corners=10pt] ($(#1 north)!0.5!(#1 south)$) -- ++(0,#3) -| (#2); } I have changed |- ++(0,#3) to -- ++(0,#3) Code: \documentclass{article} \usepackage[pdftex,active,tightpage]{preview} \setlength\PreviewBorder{2mm} \usepackage{xifthen} \usepackage{tikz} ...

2

The easiest solution here is to just give the coordinate a name so you can refer to it: \PassOptionsToPackage{rgb,x11names,svgnames,dvipsnames}{xcolor} \documentclass[tikz,border=5pt,multi]{standalone} \usetikzlibrary{arrows} \begin{document} \begin{tikzpicture}[scale=1.6, >=latex'] \draw[->] (-1.5,0)--(2.5,0) node[anchor=north] {$x$}; ...

5

For first, you can use a decoration like this. First define one \usetikzlibrary{decorations.markings,arrows.meta,bending} \tikzset{ myarrows/.style ={ postaction=decorate, decoration={ markings, mark={between positions 0.001 and 1 step 0.25 with \arrow{Latex[reversed,fill=none,flex]}} } }, } Then use a \foreach loop like ...

6

Something like that? Done with MetaPost, inserted in a LuaLaTeX program. \documentclass[border=2mm]{standalone} \usepackage{luamplib} \begin{document} \begin{mplibcode} vardef Sierpinski_var(expr A, B, C, n) = % The recursive macro if n = 0: filldraw A--B--C--cycle; else: save AC, BC, AB; pair AC[], BC[], AB[]; AC1 = 1/3[A,C]; AC2 = ...

1

You can use ampersand replacement; however, I'd not use the center environment, for better flexibility (and use $...$ instead, around the command). You can also simplify the code using matrix of math nodes. \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix} \newcommand{\SES}[3]{% \begin{tikzpicture}[every node/.style={midway},ampersand ...

3

The problem is that latex is converting the & before tikz can parse it. See example on page 1048. \documentclass{article} \usepackage{tikz} \newcommand{\SES}[3]{% \begin{center} \begin{tikzpicture}[every node/.style={midway}] \let\&=\pgfmatrixnextcell \matrix[column sep={2em}, row sep={0em}] at (0,0) { \node(A) {$0$} ; \& \node(B) {#1} ...

2

Copy/pasting that code into ShareLaTeX, it compiles with no errors and produces: What version are you using? And as a random note, compat=newest is generally not recommended. EDIT: I was able to reproduce your problem by compiling with only pdflatex filename. Since LaTeX needs to run gnuplot, you have to allow LaTeX to launch third party executables. ...

6

\documentclass{article} \usepackage{cancel,mathtools,stackengine} \stackMath \def\CBN#1#2{% \cancel{\addstackgap[6pt]{\kern6pt\displaystyle\binom{#1}{#2}\kern6pt}}% } \def\BN#1#2{% \addstackgap[6pt]{\kern6pt\displaystyle\binom{#1}{#2}\kern6pt}% } \begin{document} \[ \def\stackalignment{l} \setstackgap{S}{-5.2pt} \setstackEOL{\cr} \Shortstack{ ...

19

EDIT: changed \ifthenelse to \ifnum as suggested by percusse and Heiko. \documentclass[tikz,border=2mm]{standalone} \begin{document} \begin{tikzpicture} \foreach \n in {0,...,6} { \foreach \k in {0,...,\n} { \node (\n\k) at (\k,-\n) {${\n \choose \k}$}; \pgfmathtruncatemacro{\x}{(\n+1)/2} ...

6

This isn't precisely what the OP requests, I think, but it's similar... \documentclass{book} \usepackage{mathtools} \usepackage{cancel} \begin{document} \LARGE \boldmath % horizontal loop \foreach \x in {0,...,6} {% % vertical loop \foreach \y in {0,...,\x} {% $\cancel{\binom{\x}{\y}}$ } } \end{document}

1

The following example puts the legend below the lower left corner of the drawing. It does not use the node positioning system, but simple coordinates. Thus the lengths can be controlled easily. Text can be put with node[right] at the end point of the legend arrows: \documentclass{article} \usepackage{tikz} \usetikzlibrary{automata} \begin{document} ...

1

While the answer linked by Claudio should be useful, here is a manual method just for illustration. I have added positioning library and changed the syntax to right = of from right of =. Now you can control the distance by below = 5mm of C route. Further, I have used empty nodes so that the length becomes identical too. ...

7

Here's a suggestion using a decoration to mark points along the curves and then loop through joining them up. I'm using TikZ-level commands for the decoration which jars slightly with the low-level PGF commands that you're using; but I don't know the low-level equivalents off the top of my head. It works because decorations step along paths according to ...

1

Here is one way using the positioning library. It requires setting the offset explicitly. You might find using a \matrix as another viable approach. \documentclass[border=5pt]{standalone} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture} \draw [thick] (0,0) grid (5,5); \begin{scope}[node distance=4.1cm] ...

1

Here is one way of doing it. \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{figure}[h] \begin{tikzpicture} \begin{axis}[ ymin=-10,clip=false, xlabel=$x$, ylabel=Running Time (sec), xmode=log, every ...

3

You can say [right=<dimension> of <coordinate>] rather than just using [right] at (<coordinate>). For example, \node [above left=12mm and 15mm of A] {P}; will create the node with a P in it 12mm above and 15mm to the left of A. So, you might move P and Q something like this: \documentclass[tikz,border=5pt]{standalone} ...

4

Dependently on the complexity of your use-cases and how many of these shapes you need … here is a start. The answer consists the following: A shape declaration that borrows the rectangle ee definition from the circuits.ee (which is just a borrowed rectangle shape with .input and .output anchors). I also borrow from the linked TeXample for the text ...

1

Try a lower value for aspect. Here it is with value of 0.25. The closer it's to 1, the more like yours. If you tried 0.10 it would almost be a rectangular shape. Output Code \documentclass{article} \usepackage{tikz} \usetikzlibrary{shapes,shapes.geometric} \begin{document} \begin{tikzpicture}[node distance=5cm] \node (db1) [cylinder, ...

1

A way of doing this with MetaPost, for whom it may interest. Mainly a question of choosing the relevant scale for the x-axis, and of allowing a loop inside the labels of this axis, thanks to the \mplibtextextlabel{enable} instruction in the preamble. This makes the string arguments of each label commands be typeset by (Lua)LaTeX through the textext macro, ...

0

This is using an averaging algorithm: \documentclass[]{article}\usepackage{amsmath,mathtools,amssymb,tikz} \newlength\myheight \newcommand*\ccircled[1]{\settowidth{\myheight}{#1}% \raisebox{-.1\myheight}{\tikz[baseline=(char.base)]{% \node[shape=circle,draw,minimum size=\myheight*\myheight*.4,inner sep=1pt](char){#1};}}} \begin{document} ...

1

Here's an example using a strut: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \newcommand*\circled[1]{\tikz[baseline=(char.base)]{ \node[shape=circle,draw,minimum size=4mm, inner sep=0pt] (char) {\rule[-3pt]{0pt}{\dimexpr2ex+2pt}#1};}} \begin{document} \foreach \myn [count=\myc] in {a,b,c,d,e,p,q} {%% ...

1

A PSTricks solution: \documentclass{article} \usepackage[margin = 3cm]{geometry} % avoid `overfull \hbox' warning \usepackage{pst-plot} \usepackage{siunitx} \ExplSyntaxOn \cs_new_eq:NN \calc \fp_eval:n \ExplSyntaxOff \makeatletter \def\pst@@@hlabel#1{\ang{\calc{30*#1}}} \makeatother \begin{document} \begin{pspicture*}(-1,-4)(13.36,4.4) ...

4

I slightly changed your \foreach statement to include [evaluate=\x as \degree using int(\x*30)] and $\degree^\circ$ to print degrees. You can change the steps by changing the number 30. Output Code \documentclass[margin=10pt]{standalone} \usepackage{amsmath,amsfonts,amsthm} \usepackage{gensymb} \usepackage{tikz} \begin{document} \begin{tikzpicture} ...

3

You can use \pgfmathparse to multiply. Since you get the decimals, you may need int also like node[anchor = north] {\pgfmathparse{int(30*\x)}$\SI{\pgfmathresult}{\degree}$}; Note that I have used siunitx for the degrees. \documentclass{article} \usepackage{tikz} \usepackage{siunitx} \begin{document} \begin{tikzpicture} \draw[step = 0.5 cm, gray, very ...

1

Do not use \pgfnodeparttextbox in normal \anchors but only in \savedanchor, \saveddimen or \savedmacro. There is no guarantee that the box is the same as when the node has been created as the \anchor definitions are first executed and evaluated after the node has been typeset. In your case, you already have set up the appropriate macros \halftextheight and ...

3

You can plot in 3-D coordinates. This should get you started: Note that the order that you draw the different parts of the diagram is important: I have drawn the shaded section first so that it is "behind" the other lines. \documentclass[border=5mm,tikz]{standalone} \usepackage{mwe} \usepackage{tikz} \begin{document} \begin{tikzpicture}[every ...

2

It is easy if you do it with tikz and the code is more human readable. \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[font=\tiny] \fill[gray,opacity=0.5] (0,0) -- (2,1.98) -- (-2,1.98) -- (0,0) -- cycle; \fill (0,0) circle (2pt); \draw[shorten >= 2pt] (0,0) -- (2.02,2); \draw[shorten >= 2pt] (0,0) ...

5

Here's a more dynamic approach in which you do not have to write out each of the vertices' names. \documentclass{article} \usepackage{etoolbox} \usepackage{tkz-berge} \def\myInstance#1#2{$#1_{#2}$} \newcommand\aeAssignLabels[3]{%% \let\myexecutable\relax \foreach \myn in {#3} {%% \ifx\myexecutable\relax ...

2

The answer that you linked to does tell you how to add the labels. You first need to stop the labels being printed using \SetVertexNoLabel and then you need to manually specify the labels that you want using \AssignVertexLabel: Here's the full code to manually change the labels: \documentclass{article} \usepackage{tkz-berge} \begin{document} ...

2

Does the following help? \documentclass[tikz,border=5pt,mult]{standalone} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture}[every node/.style={draw}] \draw [help lines] (-1,-1) grid (2,2); \coordinate(A); \coordinate[right=of A](B); \draw [blue] (A) -- ++(1,1); \draw (B) -- ++(1,1); \node at (0,0) {$A$}; \path ...

6

For this sort of semi-technical sketch you might consider Metapost as an alternative tool. Here I've followed my preferred sequence to keep everything nicely organized: define the paths (relative to each other as far as possible); draw them; then add the labels. prologues := 3; outputtemplate := "%j%c.eps"; beginfig(1); % set a unit scale u := 1cm; % ...

7

I don't think it's necessary to use pgfplots. I think you can get the effect you want (and somewhat easier) using just tikz. \documentclass[border=5pt]{standalone} \usepackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture} \coordinate (Q) at (0,0); %% put this first even though you can use opacity. ...

1

It appears that if I define a command like for my operator: \tikzset{ mySum background/.style = { circle, minimum size=1.5em, fill=white, }, mySum edge/.style = { draw=black, circle, minimum size=1.5em, line width=.5pt, }, } \newcommand{\bOp}[1]{ \tikz[outer sep=0pt]{ \node [mySum background] {}; \foreach \t ...

1

One solution is to use the scale option for the tikzpicture environment to reduce the size of the plots. I have not looked for the reason for the off positions graphs. You need to check very carefully for missmatch in plotting area and the graph plotted . \documentclass{amsart} \usepackage{tikz} ...

2

Here it finally is! You can produce all three cubes by commenting and uncommenting the following code. The answer is basically the answer of Symbol 1, only modified. Note that you need to install spath package manually as informed here. The commented sections in the code are for debugging (drawing the to-be-clipped paths). The final result is satisfying. ...

1

The problem is that you are defining the new background color using CMYK model and using RGB model for the gradient. Use \definecolor{bgsummary}{rgb}{0.8,1,0.9}

6

There is a trick that can be used in some circumstances which exploits the fact that a pic is put inside a scope which can be named with the local bounding box key. Note that this will not work in trees or graphs. \documentclass[tikz,border=5]{standalone} \tikzset{pics/.cd, pic a/.style={code={ \node [fill=red!20, shape=circle] {A}; }} } ...

2

This can be done with scaled ticks=true, every y tick scale label/.append style={anchor=south west,xshift=0.2cm}, Change xshift value as you like. \documentclass[border=4]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \usepgfplotslibrary{groupplots} \begin{document} \begin{tikzpicture} \begin{groupplot}[group style={group ...

2

From the Pgf Manual (version 3.0.0), page 252: Unlike nodes, pics cannot be referenced later on. You can reference nodes that are inside a pic, but not “the pic itself.” In particular, you cannot draw lines between pics the way you can draw them between nodes. In general, whenever it makes sense that some drawing could conceivably be connected to ...

4

An Asymptote MWE: // Cantor.asy settings.tex="pdflatex"; import graph; real w=8cm,h=w; size(w,h); import fontsize;defaultpen(fontsize(9pt)); texpreamble("\usepackage{lmodern}"); xaxis(0,1,RightTicks(Step=0.20,step=0.1)); yaxis(0,1,LeftTicks (Step=0.20,step=0.1)); real eps=1e-10; real fn (real x,int n){ real u; if(n>0){ if(0 <=x ...

1

You don't need dateplot for this. Just use xtck=data along with xticklabel style= {/pgf/number format/1000 sep=,rotate=60,anchor=east,font=\scriptsize}, Here is the full code: \documentclass{book} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \begin{document} \begin{tikzpicture} \begin{axis}[width=8cm, xtick=data, xticklabel style= {/pgf/number ...

0

Here is a two column enumerate like environment using tasks package. \documentclass{amsart} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \usepackage[more]{tasks} \NewTasks[style=enumerate,counter-format=tsk[a]),label-width=1em,item-indent = 1em,column-sep =2em,after-item-skip =3ex]{choices}[\choice](2) \begin{document} \begin{choices} \choice ...

1

Here is a partial answer. You will need to then put this into your context. Personally, I would build each graphic picture with the standalone class building a 'library' of reusable diagrams. Then I would just use \inputgraphics to place the graphics where needed. But this code answers your question. However, to get the parabolas you will need to ...

Top 50 recent answers are included