Tag Info

Hot answers tagged

30

You can define the direction of the label by using label=<angle>:<label text>. To specify the distance on a per node distance, you have to supply it to the label options: label={[label distance=<distance>]<angle>:<label text>} \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[ every ...


26

This can be done by the decorations.text library gives you a text along path decoration. See the PGF/TikZ manual (v2.10) on page 337, section 30.6 Text decorations for more details. You can't draw and decorate the path at the same time directly, but can use postaction={..} to decorate the path after you have drawn it (Thanks goes to Alan Munn for this tip). ...


20

Update The result looks fine but perhaps the code can be improved. \documentclass{article} \usepackage{tikz} \usetikzlibrary{decorations,decorations.markings,decorations.text} \begin{document} \pgfkeys{/pgf/decoration/.cd, distance/.initial=10pt } \pgfdeclaredecoration{add dim}{final}{ \state{final}{% ...


20

The problem here is that TikZ applies some automatication (namely the \tikz@auto@anchor macro) that will overwrite your set anchor. We can either hijack a .code key that is applied very last in the node that is used internally for the label (yes, even after our own settings red, anchor=north) and which calls \tikz@auto@anchor: \tikzset{label ...


19

For these kinds of drawings I'd first inspect which is the most convenient way to locate nodes: you positioned manually the nodes, but in this case I think the matrix library and consequently to position the nodes in a matrix fashion is really convenient. But let's start first with the styles: \tikzset{multiplexor/.style={rectangle, draw, align=center, ...


19

You can use the fill key to “delete” the background. As the comments show you must care to set no other color after the fill key with color or just using the color name as an option. That will overwrite the color given to fill. As you can see in the example color set the color for filling, drawing and the text. \documentclass{article} \usepackage{tikz} ...


17

The following solution uses TikZ, but a minimal amount of hacks: \usepackage{tikz} \usetikzlibrary{matrix,decorations.pathreplacing} \begin{tikzpicture}[decoration=brace] \matrix (m) [matrix of math nodes,left delimiter=[,right delimiter={]}] { a & b & c & d \\ e & f & g & h \\ i & j & k & l ...


15

Here is a list of 710 keys (automatically extracted from the pgfmanual): > above above delimiter above left above left of above of above right above right of absolute accepting text accepting where alias align allow upside down ampersand replacement anchor and gate and gate IEC symbol append after command arrow box arrows arrow box east arrow arrow box ...


14

This is a possible solution mainly based on How to generate n points on a circumference and connect all of them while having constraints on the image size? The adaptation from that code concerns how the labels and the colors are customized: I developed two ways basically circumference with labels which allows to customize both; they should be inserted as ...


14

The tikz library decorations.text allows you to place text along a path. The default placement of the text is not very nice if you are trying to have the text on a line (this seems to be because the default assumption is that the text is the line). You can use the \pgftransform... commands to shift the text around. These are described in Section 79 of the ...


14

You can control the position of labels accurately with at={(axis description cs:0.5,-0.03)} The start of the axis is 0 and the end is 1. \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=middle, axis line style={->}, x label style={at={(axis description cs:0.5,-0.1)},anchor=north}, ...


13

Good to know all the other ways to do this, but I have always used xshift=<length>, and yshift=<length> to move a node or label. The blue is the default, and the red is with the option [xshift=1.0cm, yshift=0.3cm], and the green (as suggested by percusse) is using an alternate syntax to specify the x and y shift as a vector ...


13

Here is another approach exploiting the append after command option. The point is that, by referring to the anchor \tikzlastnode.center one might add, relatively to that position, labels. The new style able to accomplish this task is my label: \tikzset{my label/.style args={#1:#2}{ append after command={ (\tikzlastnode.center) node [#1] {#2} } ...


13

\documentclass{article} \usepackage{tikz} \usetikzlibrary{fit} \begin{document} \begin{tikzpicture} \node [label=label1,draw] (node1) {Node1}; \node [label={[name=l] label2},draw] (node2) at (4,2){Node2}; \node[fit=(node1)(l), draw] {}; \end{tikzpicture} \end{document}


13

You can add \tikztonodes to the path construction in the main link. \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \tikzset{ ncbar angle/.initial=90, ncbar/.style={ to path=(\tikztostart) -- ($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$) -- ...


12

The colour bar is a full-fledged axis environment, so all the usual options are available (like title). The ticks in this case are y ticks, so you can set the axis label using ylabel and the tick label style using yticklabel style: \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.6} \begin{document} \begin{tikzpicture} ...


12

Why do the blobs have tiny lines coming out of them every so often? Because the amplitude of the steps and the rounding radii are too similar. Reduce the radius or increase the amplitude and/or steps. You have to find right values by trial and error. Why are the corners of the blob at (4,1) and (14,1) not rounded? Because the path is not closed. ...


12

And a poor man's solution if compared to Claudio's answer :) \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \def\numofpoints{19} \def\circpatt{{1,0,0,1,1,0,0,1,0,1,1,0,0,0,1,0,0,1,2,3}} % 1 filled 0 empty \def\labelpatt{{1,11,2,12,3,13,4,14,5,15,6,16,7,17,8,18,9,19,10}} \node[circle,draw,minimum width=4cm] (bigc) {}; ...


12

scalebox should do the trick for you. You'll need the graphicx package. For example: \documentclass{article} \usepackage{graphicx} \usepackage{stackrel} \begin{document} \scalebox{3}{ $\stackrel[e+f+g+h^i]{a^b}{c d}$ } \end{document} For labels, you can use something like the following \begin{equation} H_{\mathrm{atom-light}}= ...


12

Update: Most of the idea exposed in the initial version is now made automatically, adding support for unnumbered chapters: \documentclass[openany]{book} \usepackage{chappg} \usepackage{pgfplots} \usepackage{lipsum} \usepackage{nameref} \usepackage{showkeys} \definecolor{ylgnbu1}{RGB}{255, 255, 204} \definecolor{ylgnbu2}{RGB}{161, 218, 180} ...


11

This is what I got: With this code: \documentclass{article} \usepackage{pgfplots,tikz,refcount,nameref,totcount,etoolbox} \usepackage{lipsum} %%%% Must be placed in the preamble %%% \newcounter{PlotMeCounter} \newcommand{\plotted}{\stepcounter{PlotMeCounter}\label{plotme:sec\arabic{PlotMeCounter}}} \makeatletter \newcommand{\lastplotted}{ ...


11

For this simple case, you can just draw a square at (A): \documentclass[tikz,border=10pt]{standalone} \begin{document} \begin{tikzpicture} \draw ( 0 , 0 ) coordinate (A) -- ( 4 , 0 ) coordinate (C) -- ( 0 , 3 ) coordinate (B) -- (0, 0); \draw [fill=red](A) rectangle ++(0.5,0.5) node[above right]{$90^\circ$}; \end{tikzpicture} \end{document} ...


11

TeX is a programming language. \label and some other constructs define variables in this language. It is common for programming languages to allow only ASCII characters in variable names. You cannot, for example, write in C int Skjærgårdsøl; Skjærgårdsøl=5; etc. The same is with TeX. Update: as commenters tell us, nowadays some programming ...


11

You can use raise to place the text \documentclass{article} \usepackage{tikz} \usetikzlibrary{decorations.text} \begin{document} \begin{tikzpicture} \node (One) at (-3,0) [shape=circle,draw] {$One$}; \node (Two) at (3,0) [shape=circle,draw] {$Two$}; \draw [->,thick,postaction={decorate,decoration={raise=-2.5ex,text along path,text ...


11

It is safest to stick to a-zA-Z0-9. Punctuation characters like " and : are subject to being made active by babel. Babel goes to some effort to make things safe even if active but you depend on the individual definitions in the individual language files. Basically the internal key is a macro name and it's a good idea to stick to things that can easily be ...


11

Instead of trying to populate the list of permitted symbolic coordinates, I would recommend to use the xticklabels from table key to set the labels. You don't need to provide an explicit ID column for this to work, you can just use x expr=\coordindex. As long as you also use xtick=data, the labels will always be assigned to the correct bars. ...


10

A label is just like any other node, so you have to specify the align of the label before the manual line breaks work, using \node [label={[align=left]<label text\\with line breaks>}] {<node text>}. Alternatively (again, like with any other node), you can specify the text width of the label, that way manual line breaks will work and the text will ...


10

For straight lines (--) a special to path could be the solution. I have defined three to styles: a=<node text>: relative positioning a position=<pos amount> (default 1.1) aa=<node text>: absolute positioning aa distance=<length> (default 1ex) bb: absolute positioning but saves the coordinate and the angle for later use: ...


10

You can only name nodes, not arbitrary parts of a drawing. In your example, if you wanted to be able to refer to the ellipse by name, you'd need to create it as a node instead of a plain ellipse. Try replacing your \draw command with this: \node[draw=blue,ellipse,name=e1,minimum width=100pt,minimum height=60pt] at (10pt,10pt) {}; To address the second ...


10

I suppose, it is only missing in minted.sty \documentclass{article} \usepackage{minted} \makeatletter \minted@define@extra{label} \makeatother \begin{document} foo \begin{minted}[frame=single,label=foobar]{c++} int main() { return 0; } int foo() {return 1; } \end{minted} bar \end{document}



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