# Tag Info

## Hot answers tagged tikz-pgf

11

You need to specify a continuous path for the fill for this to work neatly. So don't specify coordinates which you've already drawn to as that introduces a discontinuity: \documentclass[tikz,border=5pt]{standalone} \begin{document} \begin{tikzpicture} \filldraw[yellow,draw=black] (0em,0em) arc[radius=1em, start angle=180, end angle=0] -- ...

10

You are inserting more edges than the necessary. You need 4 black and 1 red. As cited by @Ignasi, you can change the node anchor to west and to east. If necessary, just use another \path command with a different anchor, if you think that some position is not good. For example, you can use south or south west and so on. \documentclass[10pt]{amsart} ...

10

With tikz-cd: \documentclass[10pt]{amsart} \usepackage{tikz-cd} \begin{document} \begin{tikzcd}[row sep=2ex] &e_{12}e_{14}e_{25}e_{25}e_{25} \\ e_{14}e_{15}e_{24}e_{25} \ar[ur,dash,start anchor=real east,end anchor=real west] \ar[r,dash,start anchor=real east,end anchor=real west] \ar[dr,dash,start anchor=real east,end anchor=real west] ...

9

Run with xelatex(takes some time) or latex->dvips->ps2pdf: \documentclass{article} \usepackage{pst-electricfield} \begin{document} \begin{pspicture*}(-6,-6)(6,6) \psframe*[linecolor=lightgray!50](-6,-6)(6,6) \psgrid[subgriddiv=0,gridcolor=gray,griddots=10] \psElectricfield[Q={[-1 -2 2][1 2 2][-1 2 -2][1 -2 -2]},linecolor=red] \psEquipotential[Q={[-1 -2 ...

8

This is very raw code but it colors \documentclass[12pt]{article} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture}[on grid] \draw[yslant=-0.5,] (0,0) rectangle +(3,3); \draw[yslant=-0.5] (0,0) grid (3,3); \foreach \x in {0,2}{ \foreach \y in {0,2}{ \fill[yslant=-0.5, blue] (\x,\y) rectangle +(1,1); }} ...

7

If you create a new command to draw a cube, you can use them as building blocks. Here is an example: \newcommand{\drawbox}[4]{ \pgfmathsetmacro \angle {30} \pgfmathsetmacro \xd {{2/3*cos(\angle)}} \pgfmathsetmacro \yd {{2/3*sin(\angle)}} \pgfmathsetmacro \x {{#1-1+(#2-1)*(\xd)}} \pgfmathsetmacro \y {{#3-1+(#2-1)*(\yd)}} ...

7

Building upon Maarten's answer, and using the \foreach, \pgfmathparse{} and \ifnum\pgfmathresult constructs, the answer could be much shorter. \documentclass[border=1mm]{standalone} \usepackage{tikz} \newcommand{\drawbox}[4]{ \draw[fill=#4] ({#1-1+(#2-1)*2/3*cos(30)},{(#2-1)*2/3*sin(30)+#3-1}) -- ({#1-1+(#2-1)*2/3*cos(30)+1},{(#2-1)*2/3*sin(30)+#3-1}) -- ...

7

I don't see the need for boxes here, you can simply use: \documentclass{article} \usepackage{tikz} \newcommand\drawline[1][black]{% \begin{tikzpicture} \draw[#1] (0pt,0pt) -- (15pt,0pt); ...

6

One way, with the arrows.meta library of pgf/TikZ v3.0. See Section 16.5 of the pgf manual for a full listing of available arrow tips and options. \documentclass[tikz]{standalone} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture} \draw[-{Latex[left]}] (0,0) -- (1,1); \draw[-{Latex[right]}] (0,1) -- (1,0); \draw[-{Diamond[left]}] (0,0.5) ...

6

Do you want something like this? Note that I'm not at all sure I understand what you are trying to do. In your comments on Gonzalo Medina's answer, you say you know that 'a' must end up in position 0 and 2, and 'b' in position 1 and 3, say. But it isn't clear how you expect this to be automated. (How can TeX tell the difference between 1 'a' and another? ...

5

\documentclass[tikz,border=4]{standalone} \begin{document} \begin{tikzpicture} \filldraw[yellow,draw=black] (0,0) arc[radius=1em, start angle=0, end angle=180] -- ++(0em,-1em) arc[radius=1em, start angle=180, end angle=0] -- ++(0em,1em) -- cycle; \end{tikzpicture} \end{document}

5

The LaTeX kernel has features for working on comma separated lists: \documentclass{amsart} \usepackage{tikz} \newcount\p \def\sillyexample#1#2{% \p=0 \addquotes\sillyexampleargtwo{#2}% \foreach\i in {#1}% {% \foreach\j in {1,...,\i}% {% \pgfmathparse{{\sillyexampleargtwo}[\j+\the\p-1]}% \node [\pgfmathresult] at (\j+\the\p,0) {\i};% }% ...

5

If you're willing to switch to the powerful forest package, this can be easily done: \documentclass[a4paper]{scrartcl} \usepackage{forest} \begin{document} \begin{forest} for tree={ parent anchor=south, child anchor=north, l sep=0.75cm } [Z,s sep=-40pt [A,calign=fixed edge angles,calign primary angle=-30,calign secondary angle=60 [a1] [a2] ...

5

PGF has an internal macro that stores the number of columns in a matrix: \pgf@matrix@numberofcolumns. So you can access it by putting, say, \makeatletter \newcommand\totcol{\pgf@matrix@numberofcolumns} \makeatother in the preamble, and use \totcol to do whatever you need with the styles.

5

I don't use fancy, but rather a home-brewed concoction. I EDITED to excise the unneeded fancy and tikz calls. Also, I did not employ your colors, but used an algorithm for varying the colors. Finally, this only works for ascii \lettergroups at present, so no umlauted e's will get a tab. I use everypage as the vehicle, employing logic similar to my answer ...

5

For the record I post also my final version. Instead of rotating the additional layers as suggested by JLDiaz I decided to scale them. Here is the result. CODE: \begin{tikzpicture}[scale=.5] \coordinate (origin) at (-4.5,-1.3); \coordinate (observer) at (-3,2.7); \coordinate (x) at ($(origin) + (1,0,0)$); \coordinate (y) at ($(origin) + (0,1,0)$); ...

5

You can use the anchors to position your arrows, and, as @Ignasi suggests, specify coordinates in terms angles. MWE \documentclass[border=2pt]{standalone} \usepackage{tikz} \usetikzlibrary{shapes.geometric} \begin{document} \begin{tikzpicture} \node(add)[regular polygon,regular polygon sides=3,draw,very thick,minimum size=2cm]{+}; ...

5

You can put the boxes one per frame by \only<slide number>. If you don't know the slide number in a large presentation, but want to display them one by one, then use \only<+>. like in \documentclass{beamer} \usepackage{tikz} \begin{document} \begin{frame} \begin{overprint} \begin{tikzpicture}[ every pin edge/.style={thick,blue!50},pin ...

4


4

A tree abhors a vacuum. You cannot leave blank lines like that in the middle of the tree. Also, you need a semicolon to finish the path, and you need to change the sibling distance to prevent the upper and lower branches from overlapping each other. I've also removed packages not needed in your MWE (but obviously you will want them in your document) and ...

4

This is an easy job for the fillbetween library from pgfplots. A simple example: The code: \documentclass{article} \usepackage{pgfplots} \usepgfplotslibrary{fillbetween} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[ xmin=100, xmax=800, ymin=0, ymax=600, domain=100:800 ] % The main line (the graph of the ...

4

It is easy using y index with pgfplots. \documentclass{article} \usepackage{pgfplotstable} \pgfplotstableread{ x y1 y2 y3 y4 0 3 4 13 14 1 5 6 15 16 2 2 3 12 13 3 4 8 14 18 4 6 9 26 19 5 8 1 18 11 6 10 2 12 12 }\mytable \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} ...

4

EDITED to handle diacritic tabs. REEDITED to correct tab colors when multiple tabs appear on a single page. Here's the fix using your existing fancy interface, rather than the home-brew concoction of my other answer. Let me show the changes: Initializations: \def\thumbnew{} \def\thumbold{} If there are no new thumbs on a page, use the last of the old ...

4

Put the tikz in a box, and deploy the box in the caption. Note that by using a temporary box as in the first MWE below, it will not play well with a \listoffigures, but that can be circumvented by using a permanent box deployed prior to the \listoffigures. \documentclass{article} \usepackage{tikz} ...

4

Without using any extra macros or packages, here is a solution which runs in linear time O(k), i.e. linear in k, where k is the number of colors (equal to 6 in your post). It is all about conditions. The two conditions that I use here are: \ifnum \k > \p{ \ifnum \k < \the\numexpr\num+\the\p+1 \relax ... These conditions precisely pick only the ...

4

Here is an example of a macro that return the length of a given piece of text up to a a maximum of \maxWidth (which is 50pt in this example) which should be adapatabe to your situation. The text passed in was an \hspace*{} so that I can know that the comparison worked: Code: \documentclass{article} \newlength\maxWidth \setlength\maxWidth{50pt} ...

4

When you nest the style definitions you need to double the number of # characters as when they get expanded they halve the numbers. So if you nest it in three levels it needs ####1 with four levels eight times etc. That's why labels don't appear because #1 holds the argument for RegionGraph but you meant cn's own argument at the time when it is defined. ...

4

You can adopt this answer: \documentclass[tikz,border=2pt]{standalone} \usetikzlibrary{intersections,arrows.meta} \usepackage{siunitx} \begin{document} \begin{tikzpicture} \draw (-0.5,5) -- (0,5) -- (0,0) -- (5,0) -- (5,5) -- (5.5,5); \draw[name path=A] (0,0)coordinate(o) -- (5,4.5)node[pos=0.8,sloped,auto]{$l_2=\SI{10}{\meter}$}; \draw[name path=B] ...

4

standalone is meant for producing images that stand alone literally. Using geometry package and trying to impose a4paper is meaning less. You should use one of the standard classes like article here. Most possibly, you will be needing a caption for your figure so it makes sense to use the figure environment that allows you to put a caption. Then, you can use ...

3

Just for fun and practicing, a solution with forest \documentclass[10pt]{amsart} \usepackage{forest} \begin{document} \begin{forest} [$e_{14}e_{15}e_{24}e_{25}$, grow'=east, for tree={parent anchor=east,child anchor=west}, l sep=.75cm [$e_{12}e_{14}e_{25}e_{25}e_{25}$] [$e_{12}e_{15}e_{24}e_{25}e_{25}$, calign with current] ...

Only top voted, non community-wiki answers of a minimum length are eligible