I am trying to set up a small TikZ library or package with pics I can reuse.

Thus, I create a file called "tikzlibraryBES.code.tex" with the following content:

   % House
   pics/house/.style args={#1/#2/#3}{
      % Define house parameters
      \newcommand\wallheight{#1}  % 0.65
      \newcommand\roofoverhang{#2}  % 0.15
      \newcommand\roofangle{#3}  % 35

      % Calculate some dependent sizes

      % draw profile of house
      \draw[line width=1pt] (-0.5,\wallheight) -- (-0.5,0) --  (0.5,0) -- (0.5,\wallheight) -- ++(-\roofangle:\roofoverhang) -- ++(180-\roofangle:\lengthroof) -- ++(180+\roofangle:\lengthroof) -- cycle;

I have another file where I want to use the library:

\documentclass[varwidth=false, border=2pt]{standalone}


% Load tikz library in file "tikzlibraryBES.code.tex"


\path (+1.5,-0.85) pic[scale=1.0] {house=0.65/0.15/35};


This works fine so far, however, I would like to have the option to create the house shape with default values by using the following command:

\path (+1.5,-0.85) pic[scale=1.0] {house};

How can I achieve this: If no arguments are provided, the some default values are used?


1 Answer 1


Simply add a .default key at the end of the \tikzset call:

  % House
  pics/house/.style args={#1/#2/#3}{
    code={ Code of the pic }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .