Tag Info

Hot answers tagged pgf-core

23

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

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

19

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

17

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

12

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

11

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

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

11

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

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

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

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

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

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

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

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

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

6

Do you want something like this? \documentclass{article} \usepackage{xparse} \usepackage{soul} \ExplSyntaxOn \NewDocumentCommand{\xparserdef}{mmmm} { \cs_new:cpn { xparser_name_#1_state_#2_#3: } { #4 } } \NewDocumentCommand{\xparserparse}{mm} { \tl_set:Nn \l_xparser_state_tl { initial } \tl_set:Nx \l_tmpa_tl { \tl_to_str:n {#2} } ...

6

Something like that : \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{calc,fadings,decorations.markings} \makeatletter \pgfkeys{/pgf/decoration/.cd, start shade/.store in = \startshade, end shade/.store in = \endshade, } \pgfdeclaredecoration{shade change}{initial}{ \state{initial}[ width = ...

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

Here's something to get you started. First, the basic points: The error messages are coming from the fact that you are trying to use dimension registers that haven't been initialised. These are \pgf@xd and so on. Only up to \pgf@xc and \pgf@yc have been declared. Unless you are doing something very tricky, it is usually possible to simply reuse the ...

6

You can also place your node with a pattern fill and decorate it if the shape declaration turns out to be difficult. \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{patterns} \makeatletter \tikzset{ mynode/.style={outer sep=1mm, pattern=vertical lines, minimum width=2cm, minimum height=1cm, append after command={ ...

6

If you modify your code to look like \pgfkeysgetvalue{/pgfplots/table/column name}\temp% \show\temp \ifx\temp\empty% \noindent Temp is empty.\\% You will see \temp is \relax in the no value case, so test for \ifx\temp\relax Don't forget to take the \show out of the production code.

6

Your \futurelet construction is just an inventive way of defining a command name to be \let to a blank space. LaTeX already has a token \@sptoken with same definition. > \mystrangemacro=blank space . l.7 \show\mystrangemacro ? > \@sptoken=blank space . l.9 \show\@sptoken LaTeX uses the construct \def\:{\let\@sptoken= } \: % this makes ...

6

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

5

This is an expansion issue: the token \n is not in your list, as you will agree. You have to communicate explicitly that you want to check for the value of \n rather than the name \n: \foreach \n in {1,...,4} {% \expandafter\ifin\expandafter{\n}% } An alternative is to use \edef (like \edef\temp{\noexpand\ifin{\n}}\temp). See ...

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