I need to print what the publisher calls "a starlet" (asterisk).
I devised the code below, but I am not sure if it is a sound code, i.e., it won't cause problems later on, within other commands and the text stream.
Is that the idiomatic way to print a special character (in this case, mathabx
's \varstar
), centered and with 1 blank line above and below?
I am using \vgrid
in order to check the vertical alignment is preserved as precisely as possible, in respect to the underlying grid.
\documentclass[
DIV=calc,
twoside,
openright,
twocolumn=false,
titlepage,
numbers=noenddot,
headinclude=true,
footinclude=true,
]{scrbook}
\usepackage{kantlipsum}
\usepackage{mathabx}
\newcommand{\aster}{$\varstar$}
\usepackage{vgrid}
\makeatletter
\newcommand{\starlet}{%
\par
\vskip -0.5pt
\noindent
\parbox{\linewidth}{
\begin{center}
\aster
\end{center}
}
\par
\vskip 0.6pt % make it fit the grid
\noindent
}
\makeatother
\begin{document}
\kant[1]
\starlet
\kant[1]
\end{document}
Best Answer
I suggest using
\centering
instead of{center}
since the former adds no vertical space and let’s you control the spacing exactly it without the need of fiddling with corrections. To use\centering
only for a part of your document enclose it in a group, i.e.{…}
, and add a\par
after it but inside the group. Then use\(add)vspace
with\baselineskip
as value to add blank lines before and after.Some notes
\addvspace
chacks wether there is already some space before and adds it only when necessary. At the of the definition you can use the normal\vspace
since there won't be any space before it.\NoIndentAfterThis
(needsnoindentafter
) is the way to prevent the indent after the command. This must be outside of the group. (see Reliable code for automatic \noindent after specific environments?)\aster
in the line, one way is to use\adjustbox{raise=1pt}{\aster}
(needsadjustbox
) or another way is\raisbox{1pt}{\aster}
(needsgraphicx
).\makeatletter/other
pair isn’t needed here since you don’t use commands containing@
as part of their name.To center a single line (box) one can also use
\hspace
with\fill
as a value: