Tag Info

Hot answers tagged

12

Not the most elegant code, there's a bit of trial and error and code repetition, but it does the job. \documentclass[tikz,border=10pt]{standalone} \usetikzlibrary{intersections,backgrounds} \begin{document} \begin{tikzpicture} \draw [thick,-stealth] (-0.5,0) --node[below]{$A$} (4,0) node[below]{$x$}; \draw [thick,-stealth] (0,-0.5) -- (0,3) ...


10

Something like this? \documentclass[tikz,border=5]{standalone} \usetikzlibrary{arrows.meta,calc} \begin{document} \begin{tikzpicture}[>={Stealth[length=1ex]}, font=\footnotesize, x=1.75cm,y=1.75cm] \foreach \j in {0,...,5}{ \foreach \i [evaluate={\c=int(\j<5 || \i > 0);}] in {0,...,3}{ \ifnum\c>0 \node [circle, draw, fill=blue!20, ...


10

You could try shadings: \documentclass[tikz,border=5]{standalone} \begin{document} \tikz[x=0.125cm,y=0.125cm] \foreach \i in {0,1,...,21} \path [left color=black, right color=white, shading angle={mod(\i,20)*180+90}] (\i*.9,0) rectangle ++(1,10); \end{document} Or fadings: \documentclass[tikz,border=5]{standalone} \usetikzlibrary{fadings} ...


9

You can use a different fill rule which is called even odd rule that fills every even numbered closed region. So if you use the following line instead of two distinct circles you get a donut fill; \path [draw=none,fill=gray, fill opacity = 0.1,even odd rule] (0,-1) circle (2) (0,-1) circle (1);


8

\documentclass[tikz,border=5]{standalone} \usetikzlibrary{positioning,calc} \begin{document} \begin{tikzpicture} \coordinate (O) at (0,0); \draw[-latex] (-1,0) node[below right = 0mm and 5mm] {$O$} -- node[pos=0.55,below]{$A$} (10,0)node[pos=0.99,below] {$x$}; \draw[-latex] (0,-1) -- node[pos=0.99,left] {$y$}(0,8); ...


8

Here is how you can do this with tikz as well as with pgfplots (which is what I would recommend you use): Notes: You have to be careful about division by zero, especially with tikz. With pgfplots there are ways to handle such cases more elegantly. So, I have changed the domain slightly below to avoid this problem. I'd recommend using an extra pair of ...


8

I think that this is an oversight, or even a bug, in the way that the table of contents is generated. Inside a latex file the \appendix command changes \@chapapp from \chaptername to \appendixname and this is used to get the right title in the chapter and appendix headings. Unfortunately, this information is NOT passed through to the table of contents file ...


7

I'd simply do the plot using the pgfplots package, which builds on pgf but is a more 'natural' interface for plotting: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} \begin{axis}[samples = 1000] \addplot[mark = none] {x * cos ( 180 / ( x / pi ) ) }; \end{axis} \end{tikzpicture} ...


7

This is possible via fillbetween library of pgfplots. Consult the manual for putting the labels and removing ticks etc. You can also search this site for examples. \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \usepgfplotslibrary{fillbetween} \usetikzlibrary{patterns} \begin{document} \begin{tikzpicture} \begin{axis}[axis ...


7

You can check the manual of pgfplots \documentclass{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[axis lines=middle,axis equal,grid=both] \addplot coordinates{(-3,1) (6,-2)}; \end{axis} \end{tikzpicture} \end{document}


7

Adjust the stars as you wish: \documentclass[tikz]{standalone} \usetikzlibrary{shapes.geometric} \begin{document} \begin{tikzpicture} [ my star/.append style={star, draw, star points=4, minimum height=10mm, star point ratio=2.5} ] \draw[step=.5cm,gray!20, very thin] (-2,-2) grid (8,8); \draw[thick,->] (0,0) -- (7,0) ...


7

Do you want to have something like this? The credits go to percusse in his answer here. I optimized the usage of styles a bit and enlarged the image for non touching arrows. The diagonal arrows in the middle got shorten a bit, as this will look better here. % arara: pdflatex \documentclass{article} \usepackage{tikz-cd} ...


6

You can use decorations.text library: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{decorations.text} \begin{document} \begin{tikzpicture}[scale=5] \coordinate [label=above right:ut] (ut) at (2,0); \coordinate [label=above right:fa'] (fa') at (4,0); \coordinate [label=above:C] (C) at (2, 2.4); \coordinate ...


6

With pgfplots: \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} \begin{axis}[ trig format plots=rad, axis lines = middle, enlargelimits, clip=false ] \addplot[domain=-2*pi:2*pi,samples=200,blue] {sin(x)}; \addplot[domain=-2*pi:2*pi,samples=200,red] {sin(x-2)}; ...


6

If the relevant functions should intersect at (4,3) then the problem seems to be that either the definition of the the function ub is incorrect or the values of \r and \s that are passed to it are incorrect. If it is the function that is incorrect then ub should be defined as 8*sqrt(\x)+10*sqrt(\y) not 10*sqrt(\x)+8*sqrt(\y). Otherwise, the function ub ...


6

The \appendix command sets the \value{chapter} to 0 and makes it \Alph. Hence you get the error. Instead of using the chapter counter, use another counter. Here I have defined a counter and stepped it up after each chapter using \xpatchcmd. \documentclass[11pt,a4paper]{book} \usepackage{lipsum} \usepackage{xpatch} \makeatletter ...


5

A pstricks solution. The pst-eucl package is designed for plane geometry. Its \pstlineAB command defines a line with two points; the line can stop at a chosen distance of the two points, wich allows for lines defined by two pointsthat are figure-wide (too long lines are cropped by the pspicture* environment). I had to patch the labels-making command in order ...


5

\documentclass[pstricks,border=20pt,12pt]{standalone} \usepackage{pst-plot,pst-node} \psset { algebraic, ticks=none, labels=none, xAxisLabel=$x$, yAxisLabel=$y$, saveNodeCoors, } \def\f{-2*sin(3*x/4-1/4)+2.5} \begin{document} % a \begin{psgraph}{->}(0,0)(-.5,-.5)(7,5){10cm}{!} \psplot[arrows=*-*]{1}{6}{\f} ...


5

I think this is a bug. I can't think of any kind of implementation logic that would justify the arrowhead on the second (dotted) line being green. \documentclass[tikz]{standalone} \usepackage{tikz} \usetikzlibrary{arrows} \begin{document} \begin{tikzpicture}[thick, >=latex] \draw [->] (0,0) -- (3,2); \draw [draw=green] (1.5,1) circle [radius=1]; ...


5

You can use a transformation on the vectors to slant the grids. I've included the rounded corners but I don't know if you need it. \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture} \foreach \x/\y in {1/1,0/0,-1/1}{ \begin{scope}[cm={1-0.2*abs(\x),0.5*\x,0,1,(\x*8cm,2*\y cm)}] \clip[preaction={draw,ultra thick},rounded corners=1cm] ...


5

You can either use the intersection library to calculate the intersection of the path (C)-(c) with another path at height 8/9C (the red path in the first picture). \path[draw,red, name path=target] ($ (ut)!8.0/9!(C) $) node [label=left:8/9] {} -- ++(1,0); \path[name intersections={of=target and C-c}] (intersection-1) coordinate[label=above:D](D) ...


5

When you put \pgfplotsset{ticks=none} after \begin{axis}, you're switching off all tick marks, including the extra x ticks that you set in the axis options. If you only want to place tick marks at some selected coordinates, simply set xtick={-5, 5}: \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} ...


5

Use the 'even odd rule': \documentclass[tikz]{standalone} \usepackage{amsfonts} \begin{document} \begin{tikzpicture} \begin{scope}[thick,font=\scriptsize][set layers] \draw [->] (-4,0) -- (4,0) node [above left] {$\Re\{z\}$}; \draw [->] (0,-4) -- (0,4) node [below right] {$\Im\{z\}$}; \iffalse% Single \draw (1,-3pt) -- (1,3pt) ...


5

In this particular case, you can simply change the drawing order i.e., draw the circles first: \documentclass[tikz]{standalone} \usepackage{amsfonts} \begin{document} \begin{tikzpicture} \path [draw=none,fill=gray, fill opacity = 0.1] (0,-1) circle (2); \path [draw=none,fill=white] (0,-1) circle (1); \begin{scope}[thick,font=\scriptsize][set ...


4

A start: \documentclass[convert=png]{standalone} \usepackage{tikz} \usetikzlibrary{matrix,positioning,shapes.geometric} \begin{document} \begin{tikzpicture}[ point/.style={circle, minimum size=4pt, inner sep=0, outer sep=0,draw=none, fill=#1}, cell/.style={draw, minimum size=20pt}, >=stealth ] \node (C){ \tikz \matrix [ ...


4

As noted by percusse, adding xlabel and ylabel to axis options solves the label issue. Another issue is plotting the correct function, which is solved by modifying the formula in \addplot. Note that pgfplots natively operates on degrees, so a conversion from radians to degrees by deg() is needed. Also an explicit multiplication must be done: pi*x instead of ...


4

Put shaded area on background layer: \documentclass{standalone} \usepackage{pgfplots} \pgfdeclarelayer{background}% determine background layer \pgfsetlayers{background,main}% order of layers \begin{document} \begin{tikzpicture} \begin{loglogaxis}[domain=1:100,xmin=1,xmax=100,ymin=1,ymax=100,grid] \begin{pgfonlayer}{background} \fill[color=black!10] ...


4

If you only want to center the node in the horizontal part of the path you can split the path in three segments: \documentclass[border=3pt]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[bob/.style={outer sep=0pt,text width=2.5em,align=center,draw}] \node[bob] (A) {1200} ; \node[bob,anchor=east] (B) at (A.west) {100} ; ...


4

Another variant with tcolorbox with call outs: \documentclass{article} \usepackage[many]{tcolorbox} \usetikzlibrary{shapes.callouts} \tikzset{note/.style={rectangle callout,fill=#1}} \newtcolorbox[auto counter]{mybox}[1][]{ colback=white, left=0.5ex, top=1ex, right=0.5ex, bottom=0ex, arc=0pt, outer arc=0pt, leftrule=1pt, ...


4

Previous note: Please, next time provide a COMPLETE minimal working (or not) example: starting from \documentclass... and finishing with \end{document} with all libraries and personal functions you use to test your code. Answer: I'm not sure about what you want to do but if you just want to add some filled circles to previous defined nodes you can do it ...



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