Tag Info

New answers tagged

3

I would propose using a cleaner syntax. Here are two other ways; \documentclass[tikz,border=1mm]{standalone} \usetikzlibrary{arrows} \begin{document} \begin{tikzpicture}[scale=1,>=latex',line width=0.7pt] \node[draw,minimum size=1cm] (n0) at (0,0) {}; \foreach \x[remember=\x as \lastx (initially 0)] in {1,...,7}{% \node(n\x) [draw,minimum size=1cm] at ...


2

EDIT: Without breaking the \foreach statement, we could have done this in two ways: \documentclass[border=1mm]{standalone} \usepackage{tikz,pgfplots} \usetikzlibrary{calc,arrows} \usepackage{xifthen} \begin{document} \begin{tikzpicture}[>=latex',line width=0.7pt] \foreach [evaluate=\i as \j using \i-1]\i in {0,...,7}{% \node (n\i) [draw,minimum size=1cm] ...


3

Mark Wibrow's solution will produce a permanent catastrophic when plotpoints=14*(2^n)+1 (for any non-negative integer n). So the following solution can be used to overcome such an issue (just for fun). \documentclass[pstricks,border=20pt,12pt]{standalone} \usepackage{pst-plot} \def\f{(x+2)/(x-1)} \begin{document} ...


3

Just for fun, with PSTricks :O \documentclass[pstricks,border=5]{standalone} \usepackage{pst-plot} \begin{document} \psset{xunit=20pt,yunit=20pt} \begin{pspicture}*(-7.5,-7.5)(7.5,7.5) \psgrid[gridlabels=0,gridcolor=gray!25,subgridcolor=gray!10](-7,-7)(7,7) \psaxes[labels=none,ticksize=-2pt 2pt]{<->}(0,0)(-7,-7)(7,7)[$x$,-90][$y$,0] ...


2

With my version of PGFplots, the \addplot command you provide doesn't even compile, so I had to guess what you want to achieve. In PGFplots you can just write fractions like this: 1/(x^2). With Matthew's comment to Jake's answer to this question you can drawn an asymptote at x=1 by using the key vasymptote=1. In order to reliably truncate the plot without ...


1

Instead of using a chain, you can position nodes using a \matrix, which behaves similar to a tabular environment with dynamic columns. If you want to know more, have a look at the PGFmanual. \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \begin{tikzpicture}[ scale=0.75, blocksgeneric/.style={ ...


3

A PSTricks solution: \documentclass{article} \usepackage{amssymb,mathtools} \usepackage{pstricks-add} \DeclarePairedDelimiter{\abs}{\lvert}{\rvert} \DeclarePairedDelimiter\set{\lbrace}{\rbrace} \newcommand*\mathsetfont{\mathbb} \newcommand*\DeclareMathSet[1]{% \expandafter\newcommand\csname set#1\endcsname{\mathsetfont{#1}} } \DeclareMathSet{C} ...


1

Here's a rough approximation...I didn't try to replicate the numbers in the MWE and haven't finetuned the details. Here's the code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{3d} \usetikzlibrary{calc} \usetikzlibrary{patterns} \begin{document} % \Yvalue{x-coordinate}{y-coordinate}{colour} \newcommand\drawYvalue[3]{% ...


9

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, ...


11

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 ...


5

I the end I wrote a transformation matrix and manually transformed the points. \documentclass[11pt]{article} \usepackage{tikz} \usepackage{tikz-3dplot} %%%< \usepackage{verbatim} \usepackage[active,tightpage]{preview} \PreviewEnvironment{tikzpicture} \setlength\PreviewBorder{5pt}% %%%> \tikzset{isometricXYZ/.style={x={(-0.866cm,-0.5cm)}, ...


3

Just tell tikz that you want a loop: \documentclass{minimal} \usepackage{tikz} \usetikzlibrary{graphs} \begin{document} \begin{tikzpicture} \graph{ 1 -> 2; 3 ->[loop below] 3; }; \end{tikzpicture} \end{document} This produces: If just write 3 -> [loop] 3; then the loop goes over node 1.


7

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) ...


16

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);


2

The original code contained a ’ (RIGHT SINGLE QUOTATION MARK in Unicode) instead of ' (APOSTROPHE in Unicode) into \tikzstyle{line} = [draw, thick, -latex’,shorten >=0pt]; With the correct tip the code compiles fine:


3

A just-for-fun solution with PSTricks. \documentclass[pstricks,border=20pt,12pt,dvipsnames]{standalone} \usepackage{pst-plot} \def\f{x*cos(1/x)} \begin{document} \begin{psgraph}[algebraic,Dx=0.025,Dy=0.01,plotpoints=1000]{->}(0,0)(-.1,-.1)(.1,.1){15cm}{!} \psplot[linecolor=Red]{-.1}{-0.005}{\f} \psplot[linecolor=Red]{0.005}{.1}{\f} ...


2

Ulrike Fischer has noted that this is a current bug report listed here and here. I include a short guide so as to preserve the suggested solution. Run kpsewhich pgfutil-latex.def on the command line to detect the location of the def file. Search for an \AtBeginDocument command that addresses the preview package. Change the previous codeblock to the ...


3

Consider using Asymptote (part of TeXLive distribution), it is perfectly suited for such tasks. Here is a brief MWE to draw wiki example with added loop to the node 5. This code use three main inputs: adjacency matrix adj, a list of coordinates pair[] vcenter and a list of self-loops directions (in degrees) real[] SelfLoopDir. // gmx.asy // ...


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} ...


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 ...


2

Something useful: scope environment. This allows to set properties such as scale/red/thick separately. \paperwidth, \textwidth, and 72.27(which is your margin). xshift, or ingeneral shift={(1,2)}. \useasboundingbox. This makes TeX reconsider the bounding box (hence the size) of tikzpicture. It is like smash or clap but far more flexible. ...


1

Just 4 fun with PSTricks. \documentclass[pstricks,border=12pt,12pt]{standalone} \begin{document} \begin{pspicture}[dimen=m](11,1.5) \foreach \i in {0,...,10}{\rput(\i,.5){\psframe(1,1)\rput(.5,.5){0}\uput[-90](.5,0){\i}}} \end{pspicture} \end{document}


3

Give node a name with, say, \node [inner sep=0pt,above right] (a) {\includegraphics[width=\textwidth]{somefig.png}}; Then you can refer to its corners with \draw (1,1) -- (a.north east) or similarly put coordinates \coordinate (b) at (a.north west);


4

Idea: §27.10 Using Several Different Layouts to Draw a Single Graph \documentclass[tikz]{standalone} \usepackage{tikz} \usetikzlibrary{graphs,graphdrawing} \usegdlibrary{layered,trees} \begin{document} \begin{tikzpicture}[sibling distance=25mm,level distance=25mm,thick, nodes={draw,circle,minimum width=30mm,align=center,inner sep=0.5em}, ...


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 ...


0

Correcting the existing answers and question with PSTricks. \documentclass[pstricks,border=15pt,12pt]{standalone} \usepackage{pst-plot} \def\f{sqrt(x+5)} \begin{document} \begin{psgraph}[Dy=5,ticks=y,labels=y]{->}(0,0)(-7,-1)(12,11){12cm}{8cm} \psset{algebraic,plotpoints=150,linecolor=red} \psplot[linestyle=dashed,arrows=*-]{-5}{5}{\f} ...


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 ...


4

More natural expression is possible in PSTricks. So, we can use x^2 instead of (\x)*(\x). Some keystrokes get saved. \documentclass[pstricks,border=30pt,12pt]{standalone} \usepackage{pst-plot} \begin{document} \begin{psgraph}[algebraic,Dy=25]{->}(0,0)(7,110){8cm}{6cm} \psplot[linecolor=blue,plotpoints=150]{.1}{6}{1/x^2} \end{psgraph} \end{document} ...


9

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 ...


1

If you mean that you want to connect your points with a smooth curve, do it like so: \documentclass[border = 10pt]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw[very thick,<->] (-0.5,0) -- (11.0,0); \coordinate (A1) at (1,1); \coordinate (A3) at (3,1.5); \coordinate (A5) at (5,1.9); \coordinate (A7) at ...


3

With pgfplots: \documentclass[border=5]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \usepgfplotslibrary{fillbetween} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=middle, axis equal, grid=both, xlabel=$\vec{k}$, ylabel=$ε(\vec{k})$, no marks, domain=-2:2, ...


3

Maybe like this: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw[help lines] (0,0) grid (10,10); \draw [->, thick] (-3,0) -- (0,0) -- (3,0); \node at (3.2,0) {$\vec{k}$}; \draw [->, thick] (0,0) -- (0,5); \node at (0,5.5) {$\varepsilon(\vec{k})$}; \draw [thick, domain=-2:2] plot (\x, {\x*\x}); ...


5

This is a sagetex approach, which gives you access to a computer algebra system, Sage, plus the Python language. There are two ways to use this package: install Sage on your computer and integrate it with LaTeX. Not such a problem in Linux but maybe troublesome with other operating systems. The second way is to sign up for the free SageMath Cloud account ...


4

The evaluate key is a part of the Tikz math library. I found this by searching the manual for evaluate=; the definition is on p. 648 of the v3.0 manual. Add math to the list of libraries loaded, and the example compiles without error: \documentclass{article} \usepackage{tikz} \usetikzlibrary{math,decorations.text,calc} % added `math' here \begin{document} ...


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); ...


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} ...


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) ...


2

Here you can find a very simple solution. It is possible to change the headings, width or the page size if you need a header or page numbers. In addition, you can very easily create a macro and use it over and over again. If you really want to have the fancy boxes, you can easily use them as well. \documentclass{article} \usepackage{chemfig} ...


1

This is one possible solution where the linear regression from pgfplotstable library is utilized. And the linear model is computed and shown in the legend. Y interception is also shown in the graph. Code \documentclass[convert = false, border=10pt]{standalone} % http://sourceforge.net/projects/pgfplots/ \usepackage{pgfplots} \usepackage{pgfplotstable} ...


1

This is a partial answer. As proposed in my comment you could use plot coordinates to avoid the two commands with a fill in order to get proper double line crossings. But somehow it messes with the <-> and I don't know why (well it should come from the second plot coordinates instance). For your sums I propose you to use the new pic env so that the ...


4

Possibly something like this? I've basically reimplemented most of the code from scratch, primarily to illustrate how it can be done more compactly: \documentclass[tikz,border=5]{standalone} \begin{document} \begin{tikzpicture}[z=(240:.25cm), >=stealth, every node/.style={circle, draw, fill=black!50, inner sep=.5ex}] \foreach \x in {1,...,6} ...


4

Just for fun with PSTricks. \documentclass[pstricks,12pt,dvipsnames]{standalone} \usepackage{amsmath} \usepackage{pstricks-add} \usepackage{pst-plot} \usepackage[nomessages]{fp} \FPeval\XMin{0-pi} \FPeval\XMax{2*pi} \FPeval\YMin{0-4} \FPeval\YMax{4} \FPeval\XOL{0-1/2} % of DeltaX \FPeval\XOR{1/2} % of DeltaX \FPeval\YOB{0-1/4} % of DeltaY ...


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 ...


3

Instead of drawing the frame using \addplot, you can create a TikZ path which describes the same shape using the plot and --plot operations. This allows you to use the clip key to restrict all drawing inside the current scope to the area described by the path. In order to use the TikZ plot operation with PGFPlots coordinates, you need to use the axis cs ...


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 ...


3

Here is a tcolorbox version. \documentclass{article} \usepackage[many]{tcolorbox} \usetikzlibrary{decorations.pathmorphing} \newtcolorbox{mybox}[1][]{% enhanced jigsaw, frame code={\path[draw=black,decorate,decoration=zigzag] (frame.south west) rectangle (frame.north east);}, left=0pt,right=0pt,top=0mm,bottom=0mm, colback = ...


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}


3

Here is one way of doing it: \documentclass{article} \usepackage[framemethod=tikz]{mdframed} \usetikzlibrary{decorations.pathmorphing} \usepackage{mwe} \begin{document} \mdfsetup{splitbottomskip=0.8cm, splittopskip=0cm, innerrightmargin=2cm,innertopmargin=1cm,% innerlinewidth=2pt,outerlinewidth=2pt, ...


2

Something like this? \documentclass[12pt]{scrartcl} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[ngerman]{babel} \usepackage{tikz} \usetikzlibrary{shapes,decorations} \usepackage{float} \usepackage{chemfig} \setdoublesep{0.357 em} \setchemrel{0pt}{1.785 em}{2.785 em} \setatomsep{1.785 em} \setbondoffset{0.18265 em} \setbondstyle{line ...


0

A PSTricks solution: \documentclass{article} \usepackage{pst-plot} \newcommand*\Label[1]{ \psline(!#1 #1 5 add sqrt)(#1,0) \psdot(#1,0) \uput[270](#1,0){$#1$} } \begin{document} \psset{unit = 0.26, algebraic} \begin{pspicture}(-8,-3)(36.4,13.5) % points \def\pointA{-5 } \def\pointB{5 } \def\pointC{30 } % drawing \psaxes[ Dy = 5, labels ...



Top 50 recent answers are included