Tag Info

New answers tagged

7

Improved version: You can use a decoration and \pgfdecoratedpathlength: The code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{decorations.markings} \makeatletter \tikzset{% measureme/.style={ decoration={ markings, mark=at position 1 with {\node[below,black,anchor=west] {My length is \pgfdecoratedpathlength};}, ...


5

Sure you can, if you use the right syntax (you need three dots in {0.1,0.2,...,1.0}): The code: \documentclass[]{article} \usepackage{tikz} \usetikzlibrary{shapes,calc} \begin{document} \begin{tikzpicture} \node[draw,regular polygon, regular polygon sides=8,minimum width=5cm] (polygon) {}; \foreach \mypercent in {0.1,0.2,...,1.0} \node[draw,circle] ...


0

nodes have inner separations. Hence when you say \draw (and.input 1) -| (a); you are not connecting to the center of node a. In this context, you have (any one of) these options. First one is to define coordinates instead of nodes: \draw (xor.input 1) coordinate[left=4mm](a); \draw[fill] (a) circle (0.02); \draw (xor.input 2) coordinate[left=7mm,](b); ...


4

Use dash pattern \documentclass[border=5]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw [line width=.5pt,dash pattern=on 1pt off 2pt]circle(0.655cm); \end{tikzpicture} \end{document} See also pag. 168 of the manual


1

The following solution is based on the hints @cfr gave in his (very good) explanation on what \begin{scope}[x={(some point)}, y={(some other point)}] does. I notived at that point, that prior to this question i was not aware on how x=and y= worked. But thanks to his explanations I saw another method so solve my problem, though it's not very different. ...


4

This is another attempt where each dot has an internal label (of Euclidean coordinate system) and utilize the labels as references to draw lines via foreach loop, some relative coordinates are used. As for labels around the diagram, only a few of them are shown, same techniques are applicable though. Code \documentclass[border=10pt]{standalone} ...


2

I'm still not sure I understand this. However, I am fairly convinced that the code neither does nor is supposed to do what you think :(. This is not an answer but it is much too long for a comment... When you write \begin{scope}[x={(some point)}, y={(some other point)}] you are setting, I think, the units of measurement. In the original example you ...


0

Or you could just fill the shape with dots (which will be rendered faster than drawing circles iteratively): \documentclass[tikz, border=5pt]{standalone} \usetikzlibrary{patterns} \begin{document} \begin{tikzpicture} \path [pattern=dots, pattern color=blue] (0,0) rectangle (5,2.5); \end{tikzpicture} \end{document}


1

You can use \foreach for iterations. The following code, draws 25 dots, 5 in rows and 5 in columns, in a square form. Then you can easily extend the code. Of course you need to read the tikz guide (find \foreach in the pdf). I think the tikz have the most comprehensive document among LaTeX packages. \begin{tikzpicture} \foreach \x in {0, 1, ..., 4} ...


1

As for the alignment question, here is a "tricky" solution: \definesubmol\nobond{-[,0.2,,,draw=none]} \begin{equation} \mbox{Preceding text:} \schemestart[][185] \chemfig[][scale=0.4]{[:-30]*6(=-(!\nobond\vphantom{\bullet})=(-*6(-=-=-=))-(!\nobond\bullet)=-)} \arrow{0}[,0]\+ \chemfig{C_2H_2} \arrow ...


1

Something like this? \begin{tikzpicture} % Set horizontal range \pgfmathsetmacro{\nx}{8} % Set vertical range \pgfmathsetmacro{\ny}{2.5} \pgfmathsetmacro{\xmin}{2*(sqrt(\ny+1)-1)/\ny} \pgfmathsetmacro{\xmint}{2/sqrt(\ny)} \pgfmathsetmacro{\xminb}{4/\ny} \pgfmathsetmacro{\xmax}{2*\nx} \begin{axis}[xmin=0,xmax=\xmax,axis x line*=middle, axis y line*=left, ...


3

You need to also apply a name path to the Brownian path and find intersections between both paths. I could do it using the complete command inside the tikzpicture but not using the macro. Probably because the name inside the macro is not public outside, but I'm not sure. \documentclass[tikz,border=2mm]{standalone} ...


2

Use domain=-4:7 \documentclass{article} \usepackage{tikz} \usepackage{amsmath} \begin{document} \begin{tikzpicture}[baseline={(current bounding box.north)}] \draw[step=1cm,color=gray!20] (-3,-2) grid (6,6); \draw[-] (-3,0) -- (6,0) node[right] {$x$}; \draw (0,0) node[below left] {$O$}; \draw[-] (0,-2) -- (0,6) node[above] {$y$}; \foreach \x in ...


0

A PSTricks solution: \documentclass{article} \usepackage{pstricks-add} \begin{document} \begin{pspicture}(-3.2,-2.1)(6.65,6.7) \psaxes[ labels = none, tickcolor = black!30, tickwidth = 0.5pt, xticksize = -2 6, yticksize = -3 6 ]{->}(0,0)(-3,-2)(6.3,6.3)[$x$,0][$y$,90] \psaxes{->}(0,0)(-3,-2)(6.3,6.3)[$x$,0][$y$,90] ...


2

You are assigning the name 2 to different nodes on different slides. To avoid this, label the nodes uniquely, even if the node content is the same: \documentclass{beamer} \usepackage{tikz} \begin{document} \begin{frame} \frametitle{Parallel Boruvka's} \tikzset{ vertex/.style = {circle,fill=black!25,minimum size=20pt,inner sep=0pt}, ...


1

I am not sure if I am allowed to copy code from that link here. However, I made the following changes: \usetikzlibrary{backgrounds} Neither arrows nor shapes are used. Nor is the verbatim package. Delete the declaration of layers. Change \tikzstyle to \tikzset: \tikzset{ style 1/.style = {settings go here}, style 2/.style = {settings go here}, ...


4

Don't leave a blank line between equation and tikz picture. You can specify a baselne for the picture. \documentclass{article} \usepackage{amsmath} \usepackage{tikz} \begin{document} \paragraph{a)} $ \begin{aligned}[t] &k:4x+3y=0 \text{en A(4,5)} \\ &d(A,k)=\dfrac{|ax_A+by_A-c|}{√{a²+b²}} \\ &\qquad =\dfrac{|4 · 4+3 · 5|}{√{4²+3²}} \\ ...


1

May be this: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} \begin{axis}[ xmax=1, xmin=0, ymax=10, ymin=-250, ] \addplot[ red, %smooth, %% this will spoil the plot domain=-5:5, samples=1000,thick ] {0.5/x²-22/x}; \end{axis} \end{tikzpicture} \end{document}


4

I cobbled this together using the example in the chemfig package (section 12.7). Edit: I also added a plain label (without arrows) next to the bond. I think this looks better because the line with arrows is not quite parallel to the line indicating the bond. \documentclass[a4paper, 12pt, twocolumn]{article} \usepackage[utf8]{inputenc} ...


1

Here is a solution using forest. It makes no sense to use a float in this context, so the tabulars cannot benefit from the automatic numbering of the table environment. However, you could use one of the methods for getting captions outside float environments if you would prefer the tables to be numbered automatically. (There are a bunch of questions ...


2

Here are some examples which may help. The first three use the same decoration. The fourth uses another text decoration where things are handled a little differently. You need to use | to delimit formatting commands when using text along path. You need to decorate as a postaction if you want the path to be drawn or whatever rather than replaced by the ...


2

The characters are typeset one by one in a box; formatting instructions should be added between |, see the manual, section 48.6, page 603. \documentclass{article} \usepackage{tikz} \begin{document} \usetikzlibrary{decorations.text} \begin{tikzpicture} \path [->,decorate,decoration={raise=-5pt, text along path, text={|\ttfamily|foo bar}, text ...


7

% arara: lualatex \documentclass{article} \usepackage{fontspec} \begin{document} \setmainfont{code2000.ttf}\symbol{"2702} \setmainfont{quivira.otf}\symbol{"2702} \setmainfont{symbola.ttf}\symbol{"2702} \end{document} If you are on pdfLaTeX: Included in TikZ: % arara: pdflatex \documentclass{report} \usepackage{tikz} \usepackage{marvosym} ...


1

With TiKZ 3.0 and node contents option it's possible to define node contents in options and fill the node without problems: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \tikzstyle{stuff_nofill}=[rectangle,draw,node contents={A}] \tikzstyle{stuff_fill}=[rectangle,draw,fill=black!20,node contents={A}] \begin{document} ...


0

TikZ 3.0 introduced node contents option which replaces {...} And another example to easily test it \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[% stuff/.style={% draw, node contents={A}} ] \node at (0,0) [stuff]; \node at (0,1) [stuff]; \node at (0,2) [stuff]; \node at (0,3) [stuff, node contents={B}]; ...


0

There is a command in TiKz for doing this : preaction. To fill a node in place of [fill=black!20] you can use [preaction={fill=black!20}]. The complete code in your case is : \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \tikzstyle{stuff_nofill}=[rectangle,draw,font={A}] ...


2

With tcolorbox it's easy to define your own shadows. You'll have to adjust box dimensions, but next code could serve as starting point. \documentclass{article} \usepackage{xcolor} %\usepackage{fancybox} \usepackage{mwe} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage[french]{babel} \usepackage[most]{tcolorbox} ...


1

This uses forest and it takes significant amounts of manual intervention to work. However, it is the best I can come up with right now. (I don't know tikz-qtree at all and I could not see any way to achieve this from the documentation. qtree might be a possibility as it allows you to execute TeX code using ! but then you would lose the power of TiKZ within ...


0

One more useful example for your reference: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{positioning} \usetikzlibrary{decorations.pathreplacing} \begin{document} \tikzstyle{curly} = [decorate,decoration={brace,amplitude=10pt},xshift=0pt,yshift=2pt] \begin{tikzpicture}[ every node/.append style={inner sep=2pt,text ...


2

You can change global path thickness as below, so you no need to change it here and there: \documentclass[tikz]{standalone} \begin{document} \tikzstyle{every node}=[font=\large] \tikzstyle{every path}=[line width=2pt] \begin{tikzpicture}[ every node/.append style={circle, draw=blue!80, inner sep=2pt, minimum size=12pt}] \node (1) at ...


2

One way to draw a vertical line with pgfplots is to specify two coordinates: Code: \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} \addplot [red, dotted, thick] coordinates {(2,-1) (2,1)} node [right] {$x=2$}; \end{axis} \end{tikzpicture} \end{document}


2

You need fit, shapes.geometric and backgrounds libraries. \documentclass[border=3mm]{standalone} \usepackage{tikz} \usetikzlibrary{automata,positioning,fit,shapes.geometric,backgrounds} \begin{document} \begin{tikzpicture}[% >=stealth, shorten >=1pt, node distance=2cm, on grid, auto, state/.append style={minimum size=2em}, thick] ...


2

If you're looking for an arbitrary coordinate around the perimeter you can use (name.number), where name is the shape name and number is an angle in degrees measured from name.east. \documentclass[border=2mm]{standalone} \usepackage{tikz} \usetikzlibrary{shapes.geometric,plotmarks} \begin{document} \begin{tikzpicture} \node[name=s, shape=regular polygon, ...


4

Defining new anchors is tricky and basically impossible without looking at the PGF code used to define the shape. But aliasing anchors is quite straightforward (once you have the command to do it): \documentclass[tikz,border=5]{standalone} \usetikzlibrary{shapes.geometric} \makeatletter \def\pgfaliasanchor#1#2#3{% \expandafter\gdef\csname ...


0

Although you want to draw trees, there's no need to use Tikz trees, tikz-qtree, forest, ... for drawing them. A matrix like in next code or just correctly positioned nodes can do the same. And next code doesn't insert a tikzpicture inside another tikzpicture which sometimes is not recommended. \documentclass[tikz,border=2mm]{standalone} ...


7

You can use mark options like mark options={draw=white,}: \documentclass[10pt]{article} \usepackage{pgfplots} \begin{document} %\tikzset{every mark/.append style={draw=white}} \begin{tikzpicture} \begin{axis}[ xmin=0, xmax=100, ymin=0, ymax=100, grid=major ] \addplot [mark=*,mark options={draw=white,}, line width=1pt] table { 10 10 ...


1

This is one possible solution via tikz-3dplot. Here numbers are used for labeling for ease of programming. Explanatory comments are added in the code. The right angles on the xy plane are found via intersections of grid lines notion, that is, finding intersection points of parellel lines that are parallel to d5-d6 and d7-d8. Code ...


5

You can use a proper rectangular clipping: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw[step=1cm,color=gray!20] (-5,-5) grid (5,5); \draw[-] (-5,0) -- (5,0) node[right] {$x$}; \draw (0,0) node[below left] {$O$}; \draw[-] (0,-5) -- (0,5) node[above] {$y$}; \foreach \x in {-5, -4, -3, -2, -1, 1, 2, 3, 4, 5} ...


4

One way is to record the name on the node to something else and use that name in the later styles. But you might use pics instead for less headache and more flexibility (in TikZ v3.0). \documentclass[tikz]{standalone} \usetikzlibrary{shapes, fit} \begin{document} \begin{tikzpicture} \tikzset{ main/.style={circle, minimum size=6mm, very ...


3

I received two great answers to my question and ended using parts of both of them, which is why I thought a complete cover page template in which people just insert their background image and title information might be helpful: \documentclass[a4paper]{article} \usepackage[svgnames]{xcolor} \usepackage{tikz} \begin{document} \tikzset{page cs/.cd, x/.store ...


5

Fixed the exponent typo now it is behaving properly. \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \draw[style=help lines] (-1.5,0) grid[step=1] (1.5,1.5); \node[fill,circle,inner sep=0.5pt] (one) at (1,0) {}; \node[fill,circle,inner sep=0.5pt] (i) at (0,1) {}; \pgfmathsetmacro\myfactor{1cm/1pt} % ...


2

This is probably not the most efficient method but I understand it ;). The following image shows the adjusted placement together with a line of small, red circles which I used to figure out the placement. Obviously you'd delete the circles before use. I've switched to a larger font with less scaling since the default fonts differ according the their size ...


4

One option: The code: \documentclass{article} \usepackage{forest} \usetikzlibrary{positioning,arrows.meta} \newsavebox\Downtree \newsavebox\Uptree \tikzset{ nleft/.style={text width=15pt,midway,left,font=\strut\scriptsize}, nright/.style={text width=15pt,midway,right,font=\strut\scriptsize}, } \savebox\Downtree{\begin{forest} for tree={ s ...


4

Since the image is scaled so that it covers the entire page, then all that is required is the width and the height of the paper to set the shift and the scale transformations. This could be done using the shift, x and y keys but I have defined a custom page cs coordinate system so that it is possible to use coordinates like (1,1) in the usual way: ...


2

One option is to use controls, but this doesn't quite get the perfectly square lines you're looking for: \begin{tikzpicture} \matrix[matrix of nodes,ampersand replacement=\&, column sep=0.5cm, row sep=0.5cm](m) { \& $\cdots$ \& $\pi_{n+1}(B)$ \\ $\pi_{n}(F)$ \& $\pi_{n}(E)$ \& $\pi_{n}(B)$ \\ $\pi_{n-1}(F)$ \& $\cdots$ \& ...


2

An option using the tikz-cd package, designed for commutative diagrams, and a style for the curved arrows: The code: \documentclass{article} \usepackage{tikz-cd} \tikzset{ curvarr/.style={ to path={ -- ([xshift=2ex]\tikztostart.east) |- (#1) [near end]\tikztonodes -| ([xshift=-2ex]\tikztotarget.west) -- (\tikztotarget)} } } ...


3

Here is solution via calc library and using a to path operation to define the curvedlink style for edges: \documentclass{beamer} \usecolortheme{wolverine} \beamertemplatenavigationsymbolsempty \usepackage{tikz} \usetikzlibrary{matrix,arrows,positioning,calc} \tikzset{ curvedlink/.style={ to path={ let \p1=(\tikztostart.east), ...


0

For future reference, I would guess that most Googlers will arrive here trying to define a style which contains a defined colour (rather than defining the colour within the style itself). That's easy to do: \begin{tikzpicture} \definecolor{dkblue}{rgb} {0.00,0.33,0.68} \tikzset{ myStyle/.style = {draw=dkblue, very thick, rectangle} } \node [myStyle] ...


1

You can use scaled x ticks=false, xticklabel style={/pgf/number format/.cd,fixed,precision=2}, to format the xticklabels automatically. Additionally the order of the colors in the color list and the order of the plots could be changed to use the cycle list color list for the plots. \documentclass{scrreprt} \usepackage{pgfplots} ...


0

I had the same error, I found a workaround by removing all highlight keywords from the \addplots and then adding one \addplots at the end printing an invisible plot with forget plot, draw=none, no marks, this time with all the highlights options and without legend. The bug appears in this MWE modified from here : \documentclass[tikz]{standalone} ...



Top 50 recent answers are included