Tag Info

New answers tagged

2

Here is an approach by using draw order and clipping. First, fill the regions with color going from the biggest to the smallest. Extend the regions a bit and and clip against the outer boundary, \begin{tikzpicture} % make outer plot as a command because it is used often during clipping \newcommand{\outline}[0]{% plot[smooth cycle]% coordinates{% (0,0) ...


2

This one goes by macro that takes 5 arguments, especially the L shape can have different vertical and horizontal lengths, which are controlled by #2 (negiative for going down) and #3. The text is defined by a stuff style that has a fixed length. #1=starting point, #2=vertically down length, #3=length of L, #4=end point, #5=stuff label. Code ...


9

Concision at the expense of clarity and/or generalisability (if that is actually a word): \documentclass[tikz,border=5]{standalone} \begin{document} \begin{tikzpicture}[>=stealth,every node/.style={text depth=0cm}, every label/.style={label distance=0.75cm, text=red, inner sep=1cm/16}] \foreach \i [count=\j, count=\k from 0] in {5,7,9,11}{ \node ...


0

You may need to do some reading of pgfmanual and its initial tutorials. \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture} \fill[gray!30] (-2.5,0.5) -- (-1.5,-1) -- (-0.5,-2) -- (1,-2.5) -- (1.5,-1.5) -- (2.2,-2) -- (2.7,-1) -- (3.5,-1.8) -- (5,-1) -- (6.5,0) -- (7.5,1) -- cycle; \draw (-2.5,0.5) -- (-1.5,-1) -- (-0.5,-2) -- (1,-2.5) -- ...


9

I would go with a matrix. \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix} \tikzset{ table/.style={ matrix of nodes, row sep=-\pgflinewidth, column sep=-\pgflinewidth, nodes={rectangle,text width=4.5em,align=center,inner sep=0pt}, text depth=1.25ex, text height=2.5ex, nodes in empty cells }, } \begin{document} ...


6

Here is a solution using SVG-Cards, inkscape and PDFLaTEX/graphicx/TikZ. I provide a Makefile : to download and to extract the SVG-Cards archive (via wget and tar), to extract each SVG card from svg-cards.svg (via inkscape) to convert each SVG card into a PDF card (via inkscape) to compile cards.tex (via pdflatex) Steps: Copy the Makefile (note: the ...


7

Try the Hobby Tikz library. It allows you to specify the incoming and outgoing angles, and produces a smoother curve. \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage{tikz} \usepackage{tkz-euclide} \usetikzlibrary{hobby} \usepackage{graphicx} \begin{document} \begin{center} \begin{tikzpicture} ...


3

You can place nodes for the labels: To extend a line you can use \draw (myand1.in 2) to (myand1.in 2 -| myor1.in 2) which draws a horizontal line from the myand1.in 2 node to a point vertically below the myor1.in 2 node. Code: \documentclass[11pt]{article} \usepackage{circuitikz} \begin{document} \begin{circuitikz} \draw (0,1) node[or port] (myor1) ...


5

You can make the graph symmetric by ensuring that the angles at which the curve leaves B and enters E match those at L. One way to do this is to plot the curve before B and after E but clip what is drawn so that only that between B and E is displayed. \documentclass[tikz,10pt,border=5pt]{standalone} \usepackage[utf8]{inputenc} \usepackage{tkz-euclide} ...


2

You'll find you get more help with TikZ questions if you include a minimal working example or "MWE." Here's something to get you started. \documentclass[a4paper]{article} \usepackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{positioning} \usetikzlibrary{shapes.multipart} \usepackage{pgflibraryarrows} ...


8

This function can be declared and evaluated directly in PGFPlots, without the need for lua. You can declare the function for the binomial coefficient using declare function={binomcoeff(\n,\k)=\n!/(\k!*(\n-\k)!);} and then use that in the declaration of the hypergeometric distribution probability mass function: declare function={ ...


2

You had a couple of syntax issues with \foreach: the major was the syntax for evaluate key. It is /pgf/foreach/evaluate=<\variable> as <\macro> using <formula>. This should work. \documentclass{standalone} \usepackage{tikz} \directlua{require("stardate.lua")} \def\StarDate#1{% \directlua{tex.sprint(StarDate("#1"))}% } ...


3

This can (if desired) be done within a single \graph command: \documentclass[tikz,border=5]{standalone} \usetikzlibrary{graphs} \usetikzlibrary{graphs.standard} \begin{document} \begin{tikzpicture}[every node/.style={draw,circle,very thick}] \graph [clockwise] { subgraph C_n [n=5,name=A, radius=2cm]; subgraph I_n [n=5,name=B, radius=1cm]; ...


2

Instead of explicitly defining a new counter \j you can use evaluate. Of course, this isn't much of a saving as you still need to define \j inside the evaluate statment, but it does save a loop: \documentclass{article} \usepackage{tikz} \usetikzlibrary{graphs} \usetikzlibrary{graphs.standard} \begin{document} \begin{tikzpicture}[every ...


4

Labels are also nodes. So TiKZ is setting each label in a circle. Since larger labels need larger circles, those labels are set further away from the labelled node. You can avoid this by explicitly specifying the usual rectangular shape for labels: \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture} [ every node/.append ...


2

A PSTricks solution: \documentclass{article} \usepackage{pst-plot} \begin{document} \psset{ yunit = 20 } \begin{pspicture}(-5,-0.05)(7.35,0.37) \psaxes[ dx = 2, Dx = 2, dy = 0.1, Dy = 0.1 ]{->}(0,0)(-5,-0.05)(7,0.35)[$x$,0][$y$,90] \psplot[ algebraic, plotpoints = 1000, linewidth = 1.5pt, linecolor = blue ...


2

In this particular case you can avoid the large denominator term by changing plot (\x,{(9*exp(\x))/(exp(\x)+9)^2}) to this plot (\x,{(9*exp(\x))/(exp(\x)+9)/(exp(\x)+9}) With this change, your example compiles without error and produces this (on my system):


5

When trying to center something on your page, what TeX essentially does is balancing out spacing on both sides of the object across the horizontal typeset width. When the element you're trying to center is larger than this width, it will align to the left and overflow the margin on the right. In the picture below, I've already added the showframe package ...


6

I'd draw the bold single bonds with the line-width command -[,,,,line width=2pt]. A bold double bond can be achieved by drawing a bold single bond backwards (angle = 180°) over the double bond: -[::180,,,,line width=2pt]. Here is an example: \documentclass[a4paper]{scrreprt} \usepackage[utf8]{inputenc} \usepackage{chemfig} ...


10

You're better served with expl3: \documentclass{article} \usepackage{amsmath,amssymb} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\makeabbrev}{mmm} { \yoruk_makeabbrev:nnn { #1 } { #2 } { #3 } } \cs_new_protected:Npn \yoruk_makeabbrev:nnn #1 #2 #3 { \clist_map_inline:nn { #3 } { \cs_new_protected:cpn { #2 } { #1 { ##1 } } } } ...


10

You need to expand and let LaTeX know that you mean a control sequence \documentclass{article} \usepackage{amssymb} \usepackage{pgffor} \foreach \x in {C,N,Q,Z,D,R,T}{\expandafter\xdef\csname\x\x\endcsname{\noexpand\mathbb{\x}}} \begin{document} \foreach \x in {C,N,Q,Z,D,R,T}{$\csname\x\x\endcsname$} \end{document}


2

PGF-Manual wrotes: It should be noted that all calculations must not exceed ±16383.99999 at any point, because the underlying computations rely on TeX dimensions. This means that many of the underlying computations are necessarily approximate and that in addition, are not very fast. TeX is, after all, a typesetting language and not ideally suited to ...


8

For plots you are better of using pgfplots: Code: \documentclass{scrbook} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=middle, xmax=6.9, xmin=-5.5, ymin=-0.05, ymax=0.35, xlabel={$x$}, ylabel={$y$}, ] \addplot [domain=-4:5, samples=100, ultra thick, blue] ...


16

Depends what you want to do with them. If you going to enter them in a paper to describe probabilities etc, better to use a font. As of Unicode 7.0 there are codepoints for card suite. Use the Symbola free font of George Douros. \documentclass{article} \usepackage{fontspec} \newfontfamily\symbola{Symbola.ttf} \begin{document} \Huge \symbola \char"1F0AB ...


20

The closest solution I found is the experimental package poker developed by Olaf Encke. This package is based on PSTricks (with all complications to run in pdflatex) further that this package is not standard and generally is not included in the Standard TeX Distributions (MaCTeX, TeXLive or MiKTeX) and it must be manually installed. I recommend these steps: ...


3

I don't think TikZ is needed. There may be easier ways of doing this but I'd go with (something like)... \documentclass[varwidth, border=.75in]{standalone} \usepackage{lipsum} \usepackage{xcolor} \usepackage{graphicx} \begin{document} {\Large\bfseries Title} \emph{Subtitle} \vskip1ex \valign{&\vfil#\cr \hsize=0pt ...


5

Put the content of minipage inside a node. You can get rid of minipage and use node itself. \documentclass{article} \usepackage{lipsum}% \usepackage{fullpage}% %% use geometry instead \usepackage{tikz}% \usepackage{graphicx}% \begin{document} \begin{tikzpicture} \node[inner sep=0pt,outer sep=0pt,text width=0.5\textwidth](a){% ...


7

You can use minipages: \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage[margin=2cm,top=3cm]{geometry} \usepackage[nottoc,notlof,notlot]{tocbibind} \usepackage[titles,subfigure]{tocloft} \usepackage{showframe,amssymb,amsmath,fancyhdr,graphicx,booktabs,array,paralist,verbatim,subfig,sectsty,mathtools,hyperref,tikz} ...


3

PGFPlots only prints minor ticks for logarithmic axes if the distance between consecutive major ticks is exactly one logarithmic unit. For example, consider this minimal example: \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ ymode=log, domain=0:5, ymin=1e0, ymax=1e7, title={\texttt ymin = ...


0

you should set yminorticks=true in your axis options, if you want them and false if you don't want them. What I would also recommend you is to set ymin, ymax and ytick manually.


2

Here's an attempt in Metapost. The picture shows d=2, d=3, d=4, and d=6. It was easier to compute and store the ratios than fiddle about doing them in MP each time. Obviously it does not work for d<2, and for d>8 you basically get a completely black disc. prologues := 3; outputtemplate := "%j%c.eps"; ratio2 = 0.78540 ; ratio3 = 0.52360 ; ...


2

It is not difficult to change the radius of the inner circle to be a function of \N. I left it constant as I am so lazy to search for such a function right now. Static version \documentclass[pstricks,border=12pt]{standalone} \usepackage{multido} \begin{document} \makeatletter \def\N{12}\degrees[\N] \begin{pspicture}[dimen=m,linejoin=1](-5,-5)(5,5) ...


3

You may define a new key named auto centering. This key adds an empty node fitted around the content of your tikzpicture. The minimum width of this node is the length given as argument (default value is \columnwidth): \usetikzlibrary{backgrounds,fit} \makeatletter \tikzset{ auto centering/.style={execute at end picture={ \node[fit=(current bounding ...


1

Just for fun with TikZ. \documentclass[tikz,border=12pt,12pt]{standalone} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \draw (-2,0) circle (12pt) (2,0) circle (12pt); \draw[->] (60:12pt)++(-2,0) -- +(1,0); \draw (60:12pt) ++(-1,0) ++ (-2pt,0) -- ($(120:12pt)+(2,0)$); \draw[->] (-120:12pt) ++(2,0) -- +(-1,0); \draw ...


4

First draw the sphere in the middle: \shade[ball color=blue] (0.5\linewidth,0) circle (10ex); %% note 0.5\linewidth To increase the width of the background to \textwidth, as you are painting the background rectangle, it is enough to draw some thing that runs across the text width like \path(0,0) --(\linewidth,0); This is an invisible line that runs ...


0

A PSTricks solution: \documentclass{article} \usepackage{pstricks-add} \def\pathLabelVert(#1)#2{ \psline(!2 #1 mul 6)(!2 #1 mul 0) \uput[270](!2 #1 mul 0){#2}} \def\pathLabelHori(#1)#2{ \psline(!6 2 #1 mul)(!0 2 #1 mul) \uput[180](!0 2 #1 mul){#2}} \begin{document} \begin{pspicture}(-0.5,-0.5)(6.35,6.4) \psaxes[labels = none, ticks = ...


6

The way it is written now, it is drawing to (120:1) and then moving the pen (without drawing) 2 units to the right. One way to solve it is to use the calc library and group the shift into one coordinate: \documentclass[tikz,border=12pt]{standalone} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \draw (-2,0) circle (1) (2,0) circle (1); ...


4

Use raise=<amount> for decorations: \documentclass{article} \usepackage{tikz} \usetikzlibrary{decorations.markings} \newcommand{\tosim}{\mathrel{% \tikz[baseline,label/.style={% postaction={% decorate,transform shape, decoration={markings,raise=.2cm,mark=at position .5 with \node {$\sim$};} } }] ...


4

The rest is given in the manual. \tikz{\def\mytheta{30}\draw (0,0) -- (\mytheta:1) |- (0,0)--cycle;}


1

Having read the comments given above, I realize the comments are useful and should be converted to an answer to finalize the problem. Jake's comment: \tikzset{every node/.append style={yshift=3mm}} Or \begin{scope}[yshift=3mm] ... \end{scope} Mark Wibrow's comment: One way for aligning the base lines would be to use anchor=base west.


3

An answer using TikZ version 3: \documentclass[border=5mm,tikz]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} \pgfarrowsdeclare{:}{:}{}{} \begin{document} \begin{tikzpicture}[ ->-/.style={arrows={:Stealth[reversed,sep=1.5ex]-}}, every node/.style={circle,draw,outer sep=0}, thick ] \node(NL) at (0,0){$N$}; \node(NR) at ...


1

I think I got it by defining my own "no-tip" arrow tip specification: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{arrows} \pgfarrowsdeclare{:}{:}{}{} \begin{document} \begin{tikzpicture}[ every node/.style={circle,draw,outer sep=0}, thick] \node(A) at (0,0){A}; \node(B) at (2,0){B}; \draw[arrows={:>[sep=10pt]-}](A)--(B); ...


3

This should do: \documentclass[border=5mm,tikz]{standalone} \usepackage{tikz} \usetikzlibrary{calc,positioning} \begin{document} \begin{tikzpicture}[ x={(5cm,0cm)},y={(2cm,-1.4cm)},z={(2.2cm,3.1cm)},scale=0.8, Dot/.style={circle,fill=black,inner sep=2pt, pin distance=0pt}, ...


2

Here is a possible solution (if I understand the question): \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{positioning,calc,backgrounds,fit} \tikzset{ every node/.style={font=\ttfamily} } \begin{document} \begin{tikzpicture} \node (n11) {x}; \node (n12) [right=of n11,xshift= 5mm] {x}; \node (n21) [below=of ...


4

Another PSTricks one: \documentclass{article} \usepackage{pstricks-add} \newcommand*\quiver[3][2cm]{% \cnodeput(0,0){A}{\strut#2}\cnodeput(#1,0){B}{\strut#3}% \ncline[offset=-1ex,nodesep=-1pt,ArrowInside=->,ArrowInsidePos=0.3,arrowsize=0.2]{A}{B}% \ncline[offset=-1ex,nodesep=-1pt,ArrowInside=->,ArrowInsidePos=0.3,arrowsize=0.2]{B}{A}% ...


2

You can draw the braces with a TikZ decoration. Admitted, they're ugly, but there's no need for a box raised to some arbitrary height. \usetikzlibrary{tikzmark,decorations,decorations.pathreplacing} \newcommand{\menge}[1]{% \begin{tikzpicture} \draw node(tree){\ignorespaces#1}; \draw [decorate,decoration=brace] (tree.south west) -- (tree.north west); ...


3

The "or something like that" in the OP includes Metapost, the Knuth-Hobby drawing language. Here's my attempt at your quiver diagram. prologues := 3; outputtemplate := "%j%c.eps"; beginfig(1); -z1 = z2 = 40 right; path c[]; c1 = fullcircle scaled 20 shifted z1; c2 = fullcircle scaled 20 shifted z2; draw c1; draw c2; label(btex $N$ etex, z1); ...


4

A somewhat similar PSTricks solution: \documentclass{article} \usepackage{expl3} \usepackage{pstricks-add} \ExplSyntaxOn \cs_new_eq:NN \calc \fp_eval:n \ExplSyntaxOff \def\quiver[#1,#2]#3#4{ \begin{figure} \centering \begin{pspicture}(\calc{2*#1+#2},\calc{2*#1}) \rput(#1,#1){#3} \rput(\calc{#1+#2},#1){#4} \cnode(#1,#1){#1}{A} ...


0

Braces for mathematical expressions are always symmetrical to the math baseline. Draw independent braces: \documentclass{article} \usepackage{forest} \usetikzlibrary{tikzmark} \begin{document} \begin{figure} \raisebox{2em}{$\left\{\rule{0pt}{2.75em}\right.$} \begin{forest} [VP [NP$\downarrow$] [\subnode{vp1}{VP}]] ...


3

You can use the externalization library. I added an automatic regeneration feature which fits better for me than the one which is implemented in the pgf-package. in your header: \usepackage{filemod} % needed for tikz externalization automation \usepackage{pgf} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \usetikzlibrary{external} ...



Top 50 recent answers are included