I would like to add a TikZ design element to a collection of documents. Presently, I accomplish this using a .sty file. More specifically, I build a style file, in this case called homework.sty, wherein I issue the package call \usepackage{tikz} and define the TikZ picture together with a call-command, \logo, that accepts a document title as its argument:


    \draw [fill=gray!30] (0,0) rectangle (1,1);
    \draw (.5,-.5) rectangle (1.5,.5);
    \draw [fill=gray] (.5,0) rectangle (1,.5);
    \node [right] at (2,.3) {\LARGE #1};

When writing a homework sheet, I then invoke the homework package and apply the logo thusly:



\logo{Sine \& Cosine} % the title is different for each homework sheet


Of course, this protocol loads TikZ (and all of its bulk) for every homework sheet. My question is thus: can the same result be accomplished in a way less cumbersome to compilation? I've contemplated exporting the TikZ graphic to postscript and using includegraphics, but that appears to be a finicky routine (see Export eps figures from TikZ). Moreover, inclusion of postscript (in my experience) itself belabors compilation, and requires the image to be stored in every homework sheet folder...

  • 1. Is the logo the same for every files? If yes, the better solution is to create a pdf file for the logo (use standalone to draw it, for example) and then save it and the sty file containing the definition of \logo command into a local tex folder so every user could load the package.
    – Sigur
    Feb 7, 2015 at 20:25
  • What's wrong with loading TikZ ? Do you have restrictions? Is PGF enough?
    – percusse
    Feb 7, 2015 at 20:27
  • @Sigur Yes, the logo is the same for every file and, after a glance at the standalone documentation, your recommendation seems promising. Would you mind explicitly demonstrating how to proceed with my MWE? Feb 7, 2015 at 20:39
  • @percusse There's nothing inherently wrong with loading TikZ, per say, but I do observe a good deal of associated material in the output report. Perhaps its effect on compiling-time is minimal and does not warrant my concern, but I just wondered if there was a "lighter" approach. Feb 7, 2015 at 20:50
  • So the argument you are passing to \logo{} doesn't vary at all? If not, why define the command to require one?
    – cfr
    Feb 7, 2015 at 21:48

1 Answer 1


pgf version without TikZ



\definecolor{logolightgray}{gray}{.85}% = gray!30


    \pgfusepath{fill, stroke}
    \pgfusepath{fill, stroke}
    \pgfnode{rectangle}{west}{\LARGE #1}{logotext}{}

  \logo{Sine \& Cosine}

Result for package pgf

picture version

The drawing is so simple, it can also be done by the picture environment. The only complication is that \framebox puts the line outside the rectangle, whereas pgf/TikZ draws the lines in the middle of the virtual rectangle, half of the line is outside and half of the line is inside. Package picture is loaded to ease the calculations.




        \framebox(##3\unitlength-.4pt, ##3\unitlength-.4pt){}%
    \begin{picture}(1.5, 1.5)(0, -.5)
      \squarefill(0, 0){1}{logolightgray}
      \squarefill(.5, 0){.5}{logogray}
      \squaredraw(0, 0){1}
      \squaredraw(.5, -.5){1}
      \squaredraw(.5, 0){.5}
    \kern.3333em % inner sep from \node
    \sbox0{\LARGE #1}%

  \logo{Sine \& Cosine}

Result for environment picture

  • 1
    (+1) for sheer bloody-mindedness. But I don't really see the point in doing all that just to avoid loading TikZ... ;).
    – cfr
    Feb 8, 2015 at 1:02

You must log in to answer this question.

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