# Tag Info

35

Version, which uses uninterrupted circles (without faint lines), where the gaps are created by clipping. This solution does not use any white background color. The measurements and colors are taken from my answer in Programming Puzzles & Code Golf. \nofiles % .aux file is not needed \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{calc} \...

22

Apparently, the idea of scoping the relevant code in pics works. Here is an example: \documentclass[tikz,border=2mm]{standalone} \usetikzlibrary{fit} \tikzset{pic shift/.store in=\shiftcoord, pic shift={(0,0)}, mytest/.pic = { \begin{scope}[shift={\shiftcoord}] \node (-A) at (0,0) {A}; \node (-B) at (0,1) {B}; ...

18

This is a work around rather than a solution. I wonder if this is a bug but my understanding of tikz is just not good enough to know for certain. Apparently, tikz no longer likes something about the to operation here within the pic. What tikz appears to be doing in the case of the \draw... to.. operation is doubling the prefix so that it looks for ...

17

This seems like a perfect problem to use the tikz library knots on! The current solution is improved from the original, which had some minor "clipping issues" (for more info, see here). I consider this solution quite elegant because the code is very simple, clear and short. \documentclass{article} \usepackage{tikz} \usetikzlibrary{knots} \begin{document} \...

15

Simply add a .default key at the end of the \tikzset call: \tikzset{ % House pics/house/.style args={#1/#2/#3}{ code={ Code of the pic } }, pics/house/.default=0.65/0.15/35 }

11

Please always read manuals first. That helps a lot, especially since you are asking for tikz basis knowledge. \documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture} \node[draw=none] (a) {File of program}; \node[draw=black,below=2 of a] (b) {Pre processor}; \node[draw=none,...

10

I dig a little bit and this is what I found: When TikZ encounters \draw(A)to(B), this is what will happen \def\tikztostart{\tikz@pp@name{A}}; usually this is simply A; \def\tikztotarget{\tikz@pp@name{B}}; usually this is simply B; The every to/.code is applied here. In the simplest case, to is merely --, so TikZ now executes \draw(\tikztostart)--(\...

10

This is indeed a bug, but for a different reason, I think this is happening at the same place when the parsing is done in \tikz@subpicture@handle@ but still I didn't understand perfectly how it goes wrong. When TikZ starts parsing the last \draw command in the pic code and encounters node names, the name prefix is already set. But the object it is parsing ...

10

Here's a working example. I've reformatted it a fair bit and added some styles to help keep straight what's doing what. \documentclass[12pt,tikz,border=3mm]{standalone} \usetikzlibrary{arrows.meta,% positioning,% shapes,calc%% } \tikzset{%% ura hub/.style={circle, anchor=center, ...

10

You need to place the \includegraphics inside a \node, as in the code below. I added some comments, but it's quite straightforward, mostly just place the node at the correct location, and set the proper size for the image. \documentclass[border=5pt]{standalone} \usepackage{amsmath} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=.5,every ...

9

Package adjustbox Your preamble already contains package adjustbox. It provides the features you need for trimming and clipping I am not sure, which spacing is needed around the image. The following example lets the image behave as it would have the height of the upper case letter H and the depth of g. \documentclass[12pt,a4paper]{article} \usepackage{...

9

Have a look at the following code: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=5] \draw[blue] (0,0) circle (1); \node[circle, fill=orange, label=above left :$A$] (A) at (95:1) {}; \coordinate[label=below left :$B$] (B) at (200:1); \coordinate[label=below left :$D$] (D) at (-110:1); \...

9

I don't think you need a sledge hammer like tikzpicture for this diagram: \documentclass{article} \usepackage{amsmath} \usepackage{rotating} \newcommand\longvertarrow[1][]{\rotatebox{-90}{$\xrightarrow{\hspace{4em}}$#1}} \begin{document} \begin{tabular}{c} File of program\\[-1.5ex] \longvertarrow[~] \\ \fbox{\enspace Pre processor\enspace}\\[-1ex] \...

8

This is a partial answer. It aims to do 2 things: demonstrate how to adjust the vertical and horizontal positioning of the second pic appropriately; clarify the issue concerning the distortion of the second tree. By default, the second pic gets aligned with the centre of the first pic. The A node in each tree is centred on (0,0) relative to the pic ...

8

You can name internal objects and refer to them by using the pic name later. \documentclass[tikz]{standalone} \usetikzlibrary{positioning} \tikzset{ pics/mp3/.style={ code={ \node[rounded corners=10*#1,draw,anchor=center, minimum height=2cm,minimum width=6cm, transform shape] (-cover) at (0,0) {}; \draw[...

8

A version in Metapost, wrapped up in luamplib. Compile with lualatex. \RequirePackage{luatex85} \documentclass[border=5mm]{standalone} \usepackage{luamplib} \begin{document} \mplibtextextlabel{enable} \begin{mplibcode} beginfig(1); path circ; pair A,B,C,D; circ = fullcircle scaled 8cm; A = point 95*8/360 of circ; B = point 200*8/...

8

I don't know the cause for this problem, it's probably related to the path construction with .pic. But if you explicitly say that the node should be in the path midway it works normally: \documentclass{standalone} \usepackage{tikz} \tikzset{thepic/.pic = {\draw (0, 0) edge node[midway]{0} (1, 0);}} \begin{document} Without \texttt{.pic}: \tikz{\draw (0, 0) ...

8

This is how .pic is defined in tikz.code.tex line 4636-4640 \pgfkeysdef{/handlers/.pic}{% \edef\pgf@temp{\pgfkeyscurrentpath}% \edef\pgf@temp{\expandafter\tikz@smuggle@pics@in\pgf@temp\pgf@stop}% \expandafter\pgfkeys\expandafter{\pgf@temp/.style={code={#1}}} } The author missed a % at the end of line 4639. I reported it as a bug here: https://...

8

For exercise (how to draw dashed line and use empty cells): \documentclass[margin=3mm]{standalone} \usepackage{tikz-cd} \usepackage{amsmath} \begin{document} \begin{tikzcd}[nodes in empty cells] X_1 \ar[r, "A"] \ar[dd, "B"'] & X_2 \ar[r, "A"] \ar[dd, "B"'] & X_3 \ar[r, "A"] \ar[dd, "B"'] & \dots \ar[r, "A"] ...

7

As an extension of the example used in the PGF documentation about pics, I propose to draw coconuts, and attach them to seagulls (as we are lacking swallows). We will use the seagull pic defined in the manual, and introduce another very simple pic called coconut, but we want to ensure that each coconut is attached to a seagull. Here is the definition of ...

7

Something like this? I used random steps decorator for the green path, and "manually" built the black path, using some key points and start/end angles. Also note the use of polar coordinates, which are more appropiate for this case than cartesian ones. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing,shapes.geometric} \...

7

It seems to me that you must use coordinate names. My guess is that the internals use \pgfpointanchor or some such, which requires a named node. It's probably good form to name your coordinates anyway! To make the angle label (say) green, set the text property of the pic (or the entire path): \draw pic["$\alpha$", draw=red, text=green, ->, angle ...

7

in year 2010 Mark Wibrow suggested me (for the similar problem) the hack which enable correct dropping show at custom fill of multi part node shape. using it in your (now really) mwe is: \documentclass[tikz, margin=3mm]{standalone} \usetikzlibrary{positioning, shadows, shapes.multipart} \pgfdeclarelayer{foreground} \...

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