I'd like to ask you about the way of putting the listing next to the tikzpicture. Is there any way to place lstlisting as it is shown below?  \documentclass[12pt]{article} \usepackage{tikz}  \begin{document} \begin{tikzpicture}[scale=3] \clip (-0.1,-0.2) rectangle (1.1,0.75); \draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4); \draw (-1.5,0) -- (1.5,0); \draw (0,-1.5) -- (0,1.5); \draw (0,0) circle [radius=1cm]; \fill[green!20!white] (0,0) -- (3mm,0mm) arc [start angle=0, end angle=30, radius=3mm] -- (0,0); \end{tikzpicture} \end{document}   My goal:
122125
I like very much the 'side-by-side' code examples in the TikZ/PGF manual...    ... and I would like to use the same thing in a manual I'm writing. I have found the source code for the codeexample environment that the TikZ/PGF manual uses for this purpose (specifically, it's located at /usr/local/texlive/2012/texmf-dist/doc/generic/pgf/macros/pgfmanual-en-macros.tex).  My (probably rather basic) question is: how can I use the same codeexample environment in my own documents? I ask because I tried compiling the example in the related question below, but the file couldn't be found.
104487
I've just started using TikZ for rendering figures for my Master thesis. I've made a few and they look good in the report. But when I tried using them in my presentation slides, some were too small and others too large. And now I'm trying to remake the figures to make them scale properly but Ḯ'm having difficulties getting it right.  What are the guidelines, if any, in making TikZ pictures scalable, in particularly when you're using nodes? Do you use relative coordinates only and avoid using absolute positioning such as above=1cm of othernode? How do you specify the size of nodes (for now I'm using minimum width and inner sep but they all require absolute sizes such as cm, pt, and so on. How about the text, should you allow that to scale with the nodes or left as it is? What about lines and arrows, should those scale and how do you go about doing that?
115185
This seems like it should be really easy but I can't seem to find it anywhere...  I'd like to be able to fine-tune the positioning of a node label.  I'm aware of the \node[label=above/below/etc:{label}] (x) {}; syntax, but that doesn't seem to give you many options on where the label goes. I'd like to be able to place the label slightly closer or farther away, or maybe in a direction other than the 8 presets available.  \tikz[label distance=x] isn't a good solution because I need it to be node-specific.
77389
could not figure out an answer to this one.  I have a tikz diagram using tikz/matrix, and I want to have a legend next to it, also using tikz/matrix. But I do not know how to refer to one particular matrix in the style definitons.  Let me visually show the problem:  \documentclass{article}  \usepackage{tikz} \usetikzlibrary{     positioning,     shapes.geometric,     matrix}  \begin{document}  \begin{tikzpicture} \tikzset{     status/.style={rectangle, draw=black, text centered, anchor=north, text=black, minimum width=2em, minimum height=2em},     mstyle/.style={column sep=10em, row sep=3em,nodes={status},font=\bfseries},     line/.style={draw,thick,-latex},     row 1 column 1/.style={nodes={fill=green}},     row 1 column 2/.style={nodes={fill=red}},     row 1 column 3/.style={nodes={fill=yellow}},     row 2 column 3/.style={nodes={fill=gray}},     row 2 column 2/.style={nodes={diamond}}, } \matrix(m)[matrix of nodes,ampersand replacement=\&amp;,mstyle]{     H \&amp; A1 \&amp; A2 \\       \&amp; {} \&amp; D \\ }; \tikzset{     status/.style={rectangle, draw=black, text centered, anchor=north, text=black, minimum width=2em, minimum height=2em},     m2style/.style={column sep=1em, row sep=1em,nodes={status},font=\bfseries}, } \matrix(m2)[right=of m, draw=black, matrix of nodes,ampersand replacement=\&amp;,m2style]{     H  \&amp; Healthy \\     A1 \&amp; Infected  \\     A2 \&amp; Infected  \\     D \&amp; Death  \\ }; \draw[line] (m-1-1) -- (m-1-2) node[pos=0.5,above,align=left] {$\#\mathrm{A1} \geq 1$ or\\$\#\mathrm{A2} \geq R$}; \draw[line] (m-1-2) -- (m-1-3) node[pos=0.5,above] {wait $\tau$ ticks}; \draw[line] (m-1-3) -- (m-2-3) node[pos=0.5,right] {wait 1 tick}; \draw[line] (m-2-3) -- (m-2-2) node[pos=0.5,above] {$p_\mathrm{replenished}$}; \draw[line] (m-2-2) -| (m-1-1) node[pos=0.2,above] {$1-p_\mathrm{infected}$}; \draw[line] (m-2-2) -- (m-1-2) node[pos=0.5,left] {$p_\mathrm{infected}$}; \end{tikzpicture}  \end{document}   I want tikzset to be limited to the scope of the first matrix m ....
70957
I have the following TikZ code which draws a grid and shows the coordinates.  To display the coordinates I am using the loop foreach.  \documentclass[12pt]{article} \usepackage{tikz}  \begin{document} \begin{tikzpicture} \draw[help lines,step=.2] (-2,-2) grid (7,4); \draw[help lines,line width=.6pt,step=1] (-2,-2) grid (7,4); \foreach \x in {-2,-1,0,1,2,3,4,5,6,7}  \node[anchor=north] at (\x,-2) {\x}; \foreach \y in {-2,-1,0,1,2,3,4}  \node[anchor=east] at (-2,\y) {\y}; \end{tikzpicture} \end{document}   Is there a way do simplify the code in this way that I have a key like show coordinates (maybe step coordinates/.initial=step ):  \draw[help lines,step=.2,show coordinates=true] (-2,-2) grid (7,4);   Or a modification of the command grid like  \draw[help lines,step=.5] (-2,-2) gridwithcoordinates (7,4);     By using pstricks it is very simple with the command \psgrid  \documentclass[12pt]{article} \usepackage{pstricks}  \begin{document} \begin{pspicture}(-2,-2)(7,4) \psgrid \end{pspicture} \end{document}   Bonus: How can I set a larger line width for the help lines at the integer coordinates (see picture above)?  (I don't know the correct words ;-) )
33690
Is it possible to load a TikZ library and make it local to a tikzpicture?  I'm writing a long document, and feel like the different TikZ libraries required for different diagrams are "littering" the namespace.
84463
I'm using beamer and want to call out a few items in a list by drawing a box around them, and, ideally, having a small comment appear next to the box, like this:
90520
I am trying to to put an lstlisting environment in the left column, but I'm getting errors. Are lstlisting and the columns environment in beamer incompatible? Or is it something else?  \documentclass{beamer}  \usepackage{remreset} \usepackage{comment} % end and begin comment \usepackage{dtklogos} % for \BibTeX  \usepackage{listings} % display code on slides; don't forget [fragile] option after \begin{frame} \usepackage{bera} % pause in listing \usepackage{color} \definecolor{lightgrey}{rgb}{0.92,0.92,0.92} % defining color for listing \definecolor{darkgreen}{rgb}{0,0.6,0} % defining color for listing  \usepackage{graphicx} % importing figure  \usepackage{verbatim} % writing code   \makeatletter \@removefromreset{subsection}{section} % creates navigation circles for every slide not section \makeatother \setcounter{subsection}{1} % creates navigation circles for every slide not section  \usetheme{Frankfurt}  \lstset{language=[LaTeX]TeX, basicstyle=\small\ttfamily, texcsstyle=*\bf\color{blue}, numbers=left, breaklines=true, keywordstyle=\color{darkgreen}, commentstyle=\color{red}, otherkeywords={$}, frame=leftline, tabsize=2, backgroundcolor=\color{lightgrey}, escapeinside=|| }  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  \begin{frame} \begin{columns}  \begin{column}{5cm} \begin{lstlisting}[float=*] \pause \end{lstlisting} \end{column}  \begin{column}{5cm} text \end{column}  \end{columns}  \end{frame}  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56474
I want a tikzpicture inside a tcolorbox. But for some reason it floats outside the box. How can I center the image correctly?    \documentclass[10pt, a4paper, twoside, titlepage, openbib]{article}      \usepackage{tikz}         %Tikz is een library die toestaat om tekeningen te maken         \usetikzlibrary{shapes}             %Shapes         \usetikzlibrary{arrows}             %Arrows         \usetikzlibrary{calc}             %Calculation         \usetikzlibrary{decorations}             %Decorations         \usetikzlibrary{backgrounds}             %Backgrounds         \usetikzlibrary{fit}             %         \usetikzlibrary{positioning}             %         \usetikzlibrary{chains}             %     \usepackage[europeanresistors,americaninductors]{circuitikz}     \usepackage{tcolorbox}         %http://mirror.unl.edu/ctan/macros/latex/contrib/tcolorbox/tcolorbox.pdf         \tcbuselibrary{listings}         \tcbuselibrary{theorems}  \begin{document}  %---Image--------------------------------------------------------------------------------------------    \begin{figure*}[ht!] %het blokschema     \centering     \begin{tcolorbox}[colback=white]     \begin{tikzpicture}[node distance = 0.2cm, auto]         \begin{circuitikz}             \draw                 (8.5,-1.) node[draw,minimum width=2cm,minimum height=2.4cm] (load) {Load}                     ($(load.west)!0.75!(load.north west)$) coordinate (la)                     ($(load.west)!0.75!(load.south west)$) coordinate (lb)                 (1,3) node[spdt,xscale=1, yscale=1,anchor=in] (myspdt1) {}                 (4,3) node[spdt,xscale=-1,yscale=1,anchor=in] (myspdt2) {}                 (5,0)   node[ground, yscale=1]{}                         to[full led]        (5,3)                         to(myspdt2.in)                 (0,0)   node[ground]{}                         to[vsourcesin]      (0,3)                         to(myspdt1.in)                 (0,2) node[right]{$V_{s}(t)$}                 (myspdt1.out 1) -- (myspdt2.out 1)                 (myspdt1.out 2) -- (myspdt2.out 2);         \end{circuitikz}     \end{tikzpicture}     \end{tcolorbox}            \caption{Het eerste probleem}          \label{fig:Het eerste probleem}  \end{figure*} %---Image--------------------------------------------------------------------------------------------  \end{document}
107533
Consider the following MWE  \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}  \draw (0,0)--(1,1) node[auto,midway] {$A$}  -- (2,0) node[auto,midway] {$B$}; \end{tikzpicture} \end{document}   I am using auto here to get automatic left/right positioning. However, I am not satisfied with the distance between the edge labels and the edge itself, which is a bit too large (my real example is a picture with much more nodes in it, so there is room for confusion if they are not very close).  Is there a way to alter this distance? I tried adding node distance=something almost everywhere, but it seems to be ignored.
35305
I use the listings package for code listings and I turned the line numbers on. But they appear left of the paragraph. I want them inside the paragraph. In the documentation it looks just right. Here is my code:  \documentclass[12pt,a4paper]{scrartcl} \usepackage{listings} \lstset{numbers=left} \begin{document} \section{Test} Test \begin{lstlisting}     test() \end{lstlisting} \end{document}
108675
This is perhaps a simple question with a simple answer, but I'm stumped as a tikz novice. What would be the best method to add an image (logo) file to the upper left-hand corner of my document?    MWE:  \documentclass[12pt]{article}  \usepackage{lipsum} \usepackage{showframe} %\usepackage{tikz} %\usepackage{graphicx}  \begin{document}  \section*{Lorem Ipsum}  \lipsum[1]  \end{document}   I wish to avoid using fancyhdr to achieve this result.
57760
I'm nesting a tikzpicture inside a tikzpicture, and having problems with the 'text width' parameter leaking through from the outer tikzpicture to the inner. (The nesting is pretty much unavoidable -- in my actual use case the tikzpicture s are defined in different macros.)   MWE:  \documentclass[a4paper,11pt,landscape]{article} \usepackage{tikz,nopageno}  \begin{document}  \newcommand{\cost}{% \begin{tikzpicture}     \node[fill=red!85!black,shape=circle,inner sep=0.3mm,draw=black,text=white] {\raisebox{0pt}[\height][0pt]{\bf 1}}; \end{tikzpicture}}  \cost  \begin{tikzpicture}     \node[text width=10mm] {\cost}; \end{tikzpicture}  \end{document}     How should I modify 'cost' so that it behaves as if text width was not set?
99007
For an example relation R: A -> B, I have the following TikZ code:  \documentclass[tikz]{standalone} \usepackage{tikz} \usetikzlibrary{shapes,backgrounds,decorations.text,patterns} \usetikzlibrary{plotmarks}  \begin{document} \begin{tikzpicture}   \begin{scope}[mark=*,mark size=1pt] % sets A &amp; B   \draw (0,0) node[ellipse, minimum height=50pt,minimum width=30pt,draw,label=above:A]{};   \draw (2,0) node[ellipse, minimum height=50pt,minimum width=30pt,draw,label=above:B]{}; % draw line and label origin a to c   \draw[-&gt;] plot coordinates {(0,10pt)} (0,10pt) node[above]{a} -- (1.9,16pt); % add end point   \node at (2,16pt) {\pgfuseplotmark{*}}; % add end label   \node[above] at (2,16pt) {c}; % draw line and label origin a to e   \draw[-&gt;] plot coordinates {(0,10pt)} (0,10pt) node[above]{a} -- (1.9,-15pt); % add end point   \node at (2,-15pt) {\pgfuseplotmark{*}}; % add end label   \node[above] at (2,-15pt) {e}; % draw line and label origin b to d   \draw[-&gt;] plot coordinates {(0,-10pt)} (0,-10pt) node[above]{b} -- (1.6,2pt);  % add end point   \node at (1.7,2pt) {\pgfuseplotmark{*}}; % add end label   \node[above] at (1.7,2pt) {d};   \end{scope} \end{tikzpicture} \end{document}   Produces:    Is there a simpler way of accomplishing this in TikZ?  It seems like a lot of work.
91546
Given the MWE below from  (compiled version on the link) :   \documentclass{article} \usepackage{float} \usepackage{tikz} \usetikzlibrary{positioning, fit, calc, shapes, arrows} \usepackage[underline=false]{pgf-umlsd} \begin{document}  \begin{figure}[H]     \centering     \begin{sequencediagram}         \newinst{c}{Client}         \newinst[6]{s}{Server}          \mess[1]{c}{Longer label}{s}         \mess[1]{s}{label}{c}         \mess[1]{c}{label}{s}         \mess[1]{s}{Longer label}{c}     \end{sequencediagram}     \caption{Client-Server messaging} \end{figure} \end{document}   I would like to add some "processing contents" on the left of the left dotted vertical bar and on the right of the right dotted  vertical bar. (If possible to add some \newline inside of these "processing contents" also)    Text example "linearised"* :           Client          Server       c^2 | ---------------&gt;| init           |                 | f=f(c^2)    g=g(f) | &lt;---------------| f         g | ---------------&gt;| check if h=g           | &lt;---------------| OK     *What I mean is that I still want to use the above tex form, which has a nice rendering.  The only thing I would like to add are information on both sides at every start and end of an arrow. I am looking for a simple solution if it is possible.  Thank you in advance for any help you may provide.
90178
I want to use math mode in lstlisting. How do I do that? How to put tab in this mode?  \begin{document}  \begin{lstlisting}[frame=single]                % Start your code-block module main() enumerated States {$S_0$,$S_1$,$S_2$,$S_3$} integer c; initial : c = 0 and States = $S_0$; endmodule \end{lstlisting}  \end{document}
82504
I would like to draw a picture that reflects some file structure. Below code works almost as expected. I need to adjust the connections between nodes so they don't start from the center of the bottom of the parent node but from near the left bottom corner.  How can I do this?  Code:  \documentclass[11pt, oneside]{article} \usepackage{tikz}                           % super package for complex and awesome drawing  \begin{document}  \usetikzlibrary{trees} \tikzstyle{every node}=[draw=black,thick,anchor=west,inner sep=2pt,minimum size=1pt] \tikzstyle{selected}=[draw=cyan,fill=cyan!30] \begin{tikzpicture}[   grow via three points={one child at (0.5,-0.7) and   two children at (0.5,-0.7) and (0.5,-1.4)},      edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]   \node {MainFolder-\{version\}}     child { node [label={[xshift=6.0cm, yshift=-0.58cm, color=gray] Documentation for developers}] {References and Documentation/}         child { node [draw=none] {main.html} }         child { node {reference/}             child { node [draw=none] {...}}         }         child [missing] {}     }     child [missing] {}     child [missing] {}     child [missing] {}     child { node {release/}         child { node [draw=none] {libAwesome.a} }         child { node [draw=none] {libAwesome.dylib} }     }; \end{tikzpicture} \tikzstyle{every node}=[] % resets borders of tables \tikzstyle{selected}=[] % resets selected  \end{document}     Ouput:    Ideal:    Any help is appreciated.