Skip to content

Commit 0d5534a

Browse files
committed
docs (tutorial1): adjust wording for option key formatting recommendations
Elaborate on the rationale behind the recommended practices for formatting option keys, clarifying the wording slightly. Signed-off-by: Alan D. Salewski <[email protected]>
1 parent d8e62df commit 0d5534a

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

doc/latex/pgfplots/pgfplots.tutorial1.tex

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ \subsection{Getting the Data Into \TeX{}}
9595
|\begin{loglogaxis} ... \end{loglogaxis}| environment for logarithmic
9696
axes).
9797

98-
Although \PGFPlots{} runs with default options, it accepts keys. Lots
99-
of keys. Typically, you provide all keys which you ``want to have''
100-
in square brackets ``somewhere'' and ignore all other keys.
98+
Although \PGFPlots{} runs with default options, it accepts option
99+
keys. Lots of option keys. Typically, you provide all keys which you
100+
``want to have'' in square brackets (|[...]|) ``somewhere'' and ignore
101+
all other keys.
101102

102103
Of course, the main difficulty is to get an overview over the available
103104
keys and to find out how to use them. This reference manual and
@@ -107,27 +108,39 @@ \subsection{Getting the Data Into \TeX{}}
107108
hopefully jump to a good match from which you can jump to \emph{the}
108109
reference section (for example about tick labels, tick positions, plot
109110
handlers, etc.). It is (and will always be) the most reliable source of
110-
detail information about all keys.
111+
detailed information about all available option keys.
111112

112113
Speaking about the reference manual: note that most PDF viewers also
113114
have a function to ``jump back to the page before you clicked on a
114115
hyperlink'' (for Acrobat Reader, open the menu View / Toolbars / More
115116
Tools and activate the ``Previous View'' and ``Next View'' buttons
116117
which are under ``Page Navigation Toolbar'').
117118

118-
Note that the code listing contains two sets of keys: the first is
119-
after |\begin{axis}[ ... ]| and the second right after
120-
|\addplot[...]|. Note furthermore that the option list after the axis
121-
has been indented: each option is on a separate line, and each line
122-
has a tab stop as first character. This is a good practice. Another
123-
good practice is to place a comma after the last option (in our case,
124-
after the value for |ylabel|). This allows to add more keys easily --
125-
and you won't forget the comma. It does not hurt at all. The second
126-
``set'' of keys after |\addplot| shows that indentation and trailing
127-
comma a really just a best practice: we simply said |\addplot[blue]|,
128-
meaning that the plot will be placed in blue color, without any plot
129-
|mark|. Of course, once another option would be added here, it would
130-
be best to switch to indentation and trailing comma:
119+
Note that the code listing contains two sets of option keys: the first
120+
is after |\begin{axis}| (the keys |title|, |xlabel|, and |ylabel|) and
121+
the second right after |\addplot| (the single key |blue|). Note,
122+
too, that the options list after the axis has been indented: each
123+
option is on a separate line, and each line has a tab stop as first
124+
character. Formatting code in this way is considered to be good
125+
practice when more than one key is specified, as it tends to be more
126+
readable than combining multiple option keys on the same line. It
127+
also facilitates commenting-out individual options.
128+
129+
Another good practice is placing a comma after the last option (in our
130+
case, after the value for |ylabel|). The trailing comma is effectively
131+
ignored -- it is not a syntax error, and it does not alter the
132+
semantic meaning of the options list. Its presence, however, allows
133+
more option keys to be appended easily in the future -- you won't
134+
forget the comma.
135+
136+
The lack of a trailing comma in the second ``set'' of keys (after
137+
|\addplot|) demonstrates that it is not strictly necessary to format
138+
an options list as recommended above. In fact, when there is only one
139+
option key, it is common to see it included on one line, as shown. In
140+
our case, we simply said |\addplot[blue]|, meaning that the plot will
141+
be placed in blue color, without any plot |mark|. If another option
142+
were to be added, though, it would be best to switch to indentation
143+
and trailing comma:
131144
%
132145
\begin{codeexample}[code only]
133146
\addplot[

0 commit comments

Comments
 (0)