How does the tikzpicture environment support multiple options, e.g. \begin{tikzpicture}[red, thick] ... \end{tikzpicture}?

According to some LaTeX documentation, multiple options are not permissible for an environment (see page 43 of this document).

Note that this question is similar to How to pass two parameters to a \newenvironment?, where it went unanswered.

Please note the distinction this question is making with regards to required parameters/arguments, which are supplied with curly braces, and options, which are supplied with rectangular braces.

  • The document you cite says that you cannot define more than one optional argument to a new environment; what's in that unique optional argument is something that the body of the definition can manage.
    – egreg
    Commented Apr 1, 2016 at 22:11

2 Answers 2


The supported syntax for \newenvironment is




and this is what's explained in the document you cite.

The first type defines an environment taking <n> mandatory arguments, so after


you have to call


With the second mode, the environment accepts a single optional argument, with default value <default>; so after


you can call the environment either with


or with


The case of tikzpicture is


What the environment does with the optional argument is left to <begin-code> to manage. When you do


there is one optional argument, which is processed to extract the TikZ options.


Technically this is only one optional argument (red,thick), two would look like \begin{tikzpicture}[red][thick] or similar.

Also the statement is not strictly true if you use low level TeX commands; just think about the signature for \newcommand{\command}[number of arguments][default value of first argument]{code}.

What happens here is that the one argument the environment gets is parsed and split along commas into several sub-arguments, that are then used in the code. A lot of packages use some derivative of xkeyval (you can read up how to use it there) but I am sure tikz rolls its own routines.

  • While this answer is complete and suggests a possible implementation of tikz, @egreg's answer addressed, clearly, the different ways in which arguments can/should be passed and their implications. Commented Apr 1, 2016 at 22:32
  • @fuzzybear3965 Well, egreg's answer addresses the possible ways arguments can/should be specified for environments defined using \newenvironment{}[][]{}{}. This answer points out that there are other ways of defining environments which are not subject to the same restrictions. However, it does also suggest that the alternatives require moving to lower-level TeX. This has not been the case for some time, but is certainly not the case now we have xparse's \New..., \Declare... etc. species of macros for defining things.
    – cfr
    Commented Apr 1, 2016 at 23:08
  • Right, I had mentioned this answer's value in regards to it addressing xkeyval as a way in which these things are handled sometimes. Thanks for addressing the other options. I have seen references to xparse and \New (not \Declare), myself. Hopefully, the information you've provided will help others. Commented Apr 1, 2016 at 23:13

You must log in to answer this question.

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