I'd add also some functions. You can declare a variable to be mandatory or optional; for instance title
might be mandatory, while subtitle
only optional. I propose the syntax
\DeclareAuthorVariable*{title} % mandatory
\DeclareAuthorVariable{subtitle} % optional
Here is the code. Change the ting
prefix to what suits you best.
% Do the branching between * and normal version
\newcommand{\DeclareAuthorVariable}{%
\@ifstar{\ting@DeclareAuthorVariable{\ting@mandatory@var}}
{\ting@DeclareAuthorVariable{\ting@optional@var}}%
}
% The main command; the internal version of \foo is \ting@foo
% The macro \ting@foo is initialized to give an error or an info
% message when used, so if the user doesn't provide a value for a
% mandatory variable, we'll catch the issue
\newcommand{\ting@DeclareAuthorVariable}[2]{%
\@namedef{ting@#2}{#1{#2}}%
\@namedef{#2}##1{\@namedef{ting@#2}{##1}}%
}
% The error and info messages
\newcommand{\ting@mandatory@var}[1]{%
\ClassError{ting}
{Missing value for mandatory variable
\expandafter\string\csname#1\endcsname}
{You have to provide a value with
\expandafter\string\csname#1\endcsname{...}}%
}
\newcommand{\ting@optional@var}[1]{%
\ClassInfo{ting}
{Missing value for optional variable
\expandafter\string\csname#1\endcsname}%
}
%%% Define two variables
\DeclareAuthorVariable*{title}
\DeclareAuthorVariable{subtitle}
If you need to branch according to a variable having been given a value or not, you can modify \ting@DeclareAuthorVariable
:
\newcommand{\ting@DeclareAuthorVariable}[2]{%
\@namedef{ting@#2}{#1{#2}}%
\@namedef{#2}##1{\@namedef{ting@#2}{##1}\@namedef{ting@#2@defined}{}}%
}
and add
\newcommand{\@ifauthorvariable}[3]{\@ifundefined{ting@#1@defined}{#3}{#2}}
so that you can say something like
\@ifauthorvariable{subtitle}
{\vspace{3ex}\textsc{\ting@subtitle}\par\vspace{3ex}}
{\vspace{1ex}---\par\vspace{1ex}}
(Here I assume that the title page will be set under \centering
; the subtitle or, if missing, a dash would be printed.)
At its simplest, one can introduce \skiplines{}
to add blank multiples of \baselineskip
.
\documentclass[oneside]{amsart}
\newcommand\skiplines[1]{\vspace{#1\baselineskip}}
\begin{document}
This is a paragraph.
This is the normal blank space between paragraphs (i.e., none).\skiplines{4}
Here, I have added 4 blank lines to allow the reader to make notes on the
printed paper.
\end{document}
As David noted in comments, however, except in unusual circumstances, one should not be routinely adding blank space manually. If there is a recurring need, the appropriate amount of space should be added as part of the document format definition (in the preamble, or in the document class itself), rather than in the document text.
Here, in the following MWE, four lines of \vspace
are embedded in each \question
and may have the number of blank lines varied as the optional argument to \question
.
\documentclass[oneside]{amsart}
\newcommand\skiplines[1]{\vspace{#1\baselineskip}}
\newcommand\question[2][4]{\item #2\skiplines{#1}}
\begin{document}
\begin{enumerate}
\question[2]{Who is buried in Grant's tomb?}
\question{What is the meaning of life, the universe, and everything?}
\question{How much wood does a woodchuck chuck, if a woodchuck could chuck wood?}
\end{enumerate}
Back to your regularly scheduled document.
\end{document}
Best Answer