# Tag Info

24

Since you want to use this for UML diagrams, I think a custom node shape is the right way to go here. It's a lot more overhead and requires getting under PGF's hood/bonnet, but the payoff is that it the drawing code looks just like any other TikZ code: \documentclass{article} \usepackage{tikz} \makeatletter \pgfkeys{/pgf/.cd, parallelepiped offset ...

21

Drawing a cube seems to be a fairly common task! There are a few other questions here that involve drawing cubes. It's not always right to merge them, but I thought it worth doing a little more than just linking. So this answer is a Community Wiki (so almost anyone can update it) list of the other cubical questions here. The intent is to include at least ...

20

I know that this is not what the question was about, but it is an attempt of a 3D cube, with perspective. I don't know how to do it with grids like Stefan's example, but with coordinate calculations and intersections, one can do something like this. It is not mathematically correct, but I think it looks pretty good. \documentclass[]{article} ...

20

I'm sure that there are better ways, but here's one: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \pgfmathsetmacro{\cubex}{2} \pgfmathsetmacro{\cubey}{1} \pgfmathsetmacro{\cubez}{1} \draw[red,fill=yellow] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle; \draw[red,fill=yellow] (0,0,0) -- ...

18

\pgfimage currently uses \includegraphics internally for every output format (i.e. driver) except for pdftex where it uses its own pdftex primitives to include the image (which are also used in \includegraphics BTW). A notable difference is that PGF provides different macros to declare the image first and then use it multiple times, while \includegraphics ...

14

The internal unit ex is explained in the TeXbook as follows: ex is the "x-height" of the current font. It is taken from \fontdimen5, as explained in Appendix F. So the value depends on the font. \nullfont\edef\x{\the\dimexpr 3ex-1ex\relax} \show\x gives > \x=macro: ->0.0pt. If you use ex in LaTeX before \documentclass, you get 0pt as no ...

14

Sometimes we only need a virtual path, or a totally transparent path just to compute some coordinates, intersections, and so on. To do an invisible path we use \path and if you want to put some ink on it you use \draw. Example: Here is an example where I used some paths to compute the intersections. \documentclass{report} ...

13

I tried an approach with Tikz, by drawing a line around an existing node and turning that into a newcommand. You can change almost everything according to your needs. The only exception is relative positioning. I'm still having a problem with it because I can't seem to make it work. I've tried different tweaks but I haven't found the solution yet. (If ...

13

Declaring shapes is one of the most useful features of the tikz/pgf library. It can be extended by endless choice and really is a good idea. The problem with the shapes is the difficulties one has to go through to get it to work. This is due to the low-level coding that is necessary and essentially a good bookkeeping of variables is the problem. If one is ...

13

This led to some additions to the spath library, including better bounding box handling and more extensive path transformations. The latest version is on Launchpad (it should still be regarded as alpha code). To address the original matter: the problems were caused by bounding boxes. The original spath code made no mention of bounding boxes, so the fading ...

12

A brute-force attempt. The versions where only one or two opposite sides are drawn wouldn’t have a correct area to fill. One will need to use the special \behindbackgroundpath for this. The same is true for the other versions with two adjacent sides: they create a triangular area. But you then need to use an extra key: /pgf/open rectangle fill. You can ...

11

I don't know any good place from where to learn all the material, but I can try to give you a few pointers. The following comes with the caveat that I only dabbled in writing shaders a bit and am certainly no expert on this topic. Abstractly, a functional shader is given by a function f: R → [0,1]³, where R is some subset of ℝ² (usually a rectangle) and ...

10

Here's an example for a shaded 3D cube with TikZ: \documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture}[on grid] \shade[yslant=-0.5,right color=gray!10, left color=black!50] (0,0) rectangle +(3,3); \draw[yslant=-0.5] (0,0) grid (3,3); \shade[yslant=0.5,right color=gray!70,left color=gray!10] ...

10

In a TikZ picture, the current font is set to \nullfont, generally, in order to avoid casual typesetting; this font has all parameters equal to zero, so 1em = 1ex = 0pt when the font is \nullfont. On the other hand, 1sp is very small, because 65536sp=1pt, so it's almost impossible to appreciate a displacement by 500sp. Just set the lengths before entering ...

9

Since PGF 2.10, arguments modifying path style no longer work when you put them after the to keyword. They should be put directly after the \draw command. Like this: \begin{tikzpicture} \draw[->, line width=2mm] (0,0) to (3,1); \end{tikzpicture} All in all, this took me weeks to find out. For quite a while, I even downgraded to PGF 2.00 because ...

9

I don't think that these PGF arrays are suitable for your task. You can use an implementation of mine which might be better. But although that implementation proved to be useful, it has quite high demands on TeX skills and has no real support. In the following, I will elaborate on that implementation. You can read it, and then you should go back and ...

9

One has always to remember that \foreach processes the token list to be repeated inside a group, so redefinitions and assignments must be global: \documentclass{article} \usepackage{pgffor} \begin{document} \def\amspace{\global\let\amspace\space} \newcount\nra *\foreach\x in {1pt,2pt,...pt,10pt}{% \global\advance\nra by1\relax \amspace\texttt{\x ...

8

As a different approach to creating complicated shadings: You could use a three-dimensional pgfplots plot that is viewed from above, and use the colormap feature to get the colours. For example, the shading mentioned in your comment, (1/r)*(cos(theta))^2 in a polar coordinate system, could be achieved like this: \documentclass{article} ...

8

I don't see a way to get the stroke colour from PGF itself (\pgfgetsstrokecolor isn't a defined macro) but fortunately TikZ stores the colour in its own memory space and so it is possible to use that to get the colour. There are three such storage places: \tikz@strokecolor \tikz@fillcolor tikz@color . The first two are macros, the last two are colours. ...

7

7

Next solution is inspired in Qrrbrbirlbel's answer to Fill a node shape, although in this case we need two different orders to fill and drawthe shape. \documentclass[tikz,border=3mm]{standalone} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture}[ bottomflat/.style={ append after command={% \pgfextra ...

7

I would like to present some of my findings, if you excuse me my source code shuffle digging. It would be much easier to draw/program it from scratch with easy access via TikZ interface for improvements, but it was a challenge to follow request as close as possible, it has its reasons, I suppose. I took it as an exercise to improve my TeX source code ...

6

Next is the code for a switch shape. I've taken the code from the forbidden sign (pgflibraryshapes.symbols.code.tex) and added the missing line. \documentclass[tikz]{standalone} \usetikzlibrary{positioning} \makeatletter \pgfdeclareshape{switch} { \inheritsavedanchors[from=circle] % this is nearly a circle \inheritanchorborder[from=circle] ...

6

I put some nonlinear transformation but I have no idea whether the result is meaningful or not. I can try to check for mistakes if you can show the before and after result One thing to consider is that r -> log(r) is a pretty contractive transformation so I boosted up by converting the units to centimeters. I don't know whether it is wise to do. ...

6

As far as I can tell, this is used to be able to tell where a path is started. The string \tikz@signal@path shows up again in line 41 of tikzlibrarymatrix.code.tex. My interpretation of the code (which might be wrong!) is that the following happens to construct a cell in a matrix with the matrix of nodes option: First the general matrix code starts ...

6

For some reason, having spaces around the = will break things (even though they are used in the manual). The following code compiles for me: \documentclass{article} \usepackage{tikz} \usepgfmodule{oo} \pgfooclass{mapEntry}{ % \method mapEntry() {% } } \begin{document} \pgfoonew \myObj=new mapEntry() \end{document}

6

The type 4 functions mentioned in the TikZ manual are what are called Postscript Calculator Functions, a subset of Postscript which is supported by the PDF specification. The actual subset is described in chapter 7 of the PDF 1.7 reference manual. Type 4 functions themselves are described in detail in Chapter 4 of the Postscript Language Reference 3rd ...

6

There's a few issues here: As cjorssen says in the comment, the first argument of \savedanchor has to be a command sequence. I'd go for \<part>anchor. Saved anchors are not anchors. They then have to be used to define anchors. So you need \anchor{true}{\trueanchor} and likewise (and the true and false anchors have to be defined). If you're using ...

6

I improved your code a bit, I see that in the mean time Andrew has already explained everything I was going to in here. I will just add the code, so that you have a starting point. \documentclass{article} \usepackage{tikz} \usetikzlibrary{shapes.multipart} \begin{document} \makeatletter \newbox\pgfnodepartfalsebox \newbox\pgfnodeparttruebox ...

6

\lstinputlisting doesn't seem to expand its arguments, so the \x is not replaced with the current number. You can work around this by using an \edef (an "expanded definition") to define a new macro that contains your \lstinputlisting line with expanded arguments, and then call that. The lines \edef\dolisting{\noexpand\lstinputlisting[linerange=P\x-FIN\ ...

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