Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to check the the source code used to implement the standard rectangle shape in PGF/TikZ. I was thinking about searching for something like \pgfdeclareshape{rectangle} inside the PGF files but I have no idea where to look.

I've found a pgfbaseshapes.sty file in texmf-dist/tex/latex/pgf/basiclayer/ but it is almost empty and tagged as obsolete.

Any hint on where should I look?

It would also be super nice if someone could briefly explain how the PGF/TikZ code is organized into files, i.e. where should one look for the code of a certain shape, a library, etc.

share|improve this question
2  
A lot of them are found in /usr/local/texlive/<versionnumber>/texmf-dist/tex/generic/pgf/frontendlayer/tik‌​z/libraries/... You'll find them typically in names that end with .code.tex. I can't speak to the organization- I'm sure one of the tikz gurus will be around soon :) –  cmhughes Jun 18 '13 at 17:37
    
thank you @cmhughes for some obscure reason I was limiting myself to the tex/latex/ folder... Now I've found all sort of shapes code except that for the standard rectangle :D –  dcmst Jun 18 '13 at 17:49
1  
@dcmst: The really basic node shapes (including rectangle) are defined in pgf/generic/pgf/modules/pgfmoduleshapes.code.tex –  Jake Jun 18 '13 at 17:56
    
thanks @Jake. After discovering the right directory to look in (thanks to @cmhughes) I have to say that the files structure is not that complicated as I thought before. –  dcmst Jun 18 '13 at 21:24
3  
I generally browse libraries via shell; for example, you can find paths saying kpsewhere tikzlibraryshapes.code.tex or kpsewhere pgflibraryshapes.code.tex and of course have a look to the code via nano $(kpsewhere tikzlibraryshapes.code.tex) or nano $(kpsewhich tikzlibraryshapes.code.tex). –  Claudio Fiandrino Jun 19 '13 at 10:49

1 Answer 1

up vote 5 down vote accepted
  1. The first answer is already mentioned in the comments. Basic answer is look for the TeX distro's tex/pgf/generic folder. (TikZ/PGF has different implementation details depending on the driver choice so it further classifies code into ConTeXt/Lua/Xe/PDF/La(TeX) etc.) Generic tends to include the driver-independent code.

    To add yet another option from TeXnicCenter, if you use Ctrl+Shift+F and enter C:\Program Files (x86)\MiKTeX 2.9\tex\generic\pgf as the Use Directory it will search for all relevant PGF files in a separate Find window (for which there are two). A screenshot

    enter image description here

    Strangely, if it doesn't find anything in a file it says Cannot access file! but in fact it does access all files.

  2. The organization for the files roughly;

    1. Front-End Layer (TikZ files) tikz.code.tex is the main file for everything.
    2. Basic Layer (PGF files)
    3. System Layer (Driver related lowest-level files)
    4. Libraries (PGF versions)
    5. Math, Keys, Utilities etc.

    When we use \usetikzlibrary{<lib name>} it looks for the library file

    tikzlibrary<lib name>.code.tex
    

    within the Front-End folder TikZ. However, these library calls also involve

    pgflibrary<lib name>.code.tex
    

    under the hood. So we can also argue that there is a front-end to the libraries too which is mostly used to get the main functionality in a convenient manner and passes onto the actual PGF code.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.