Vertical spacing using kern in a custom symbol

I've created a new symbol using the macro:

\documentclass{article}

\usepackage{amssymb}
\newcommand{\qc}{$\square$\kern-0.58em{s}}
\begin{document}
\qc
\end{document}


However I'd like the letter 's' to be centered vertically, how can I do this?

• How is this symbol going to be used? In text mode, or in math mode? Should the lower line of the square be placed on the baseline (and hence should s be above the baseline), or should the square be pushed down a bit so that the s is on the baseline?
– Mico
Mar 12, 2017 at 16:21
• @Mico, the use is as a custom replacement of the QED symbol. I'd like the 's' to raised a bit so it does not intersect the lower line of the square. Moving either component is fine. Mar 12, 2017 at 17:05

If the baseline of the open square is supposed to be on the typographic basedline, the following code may be of interest. (By using \ooalign, one doesn't have to insert a kern after the "s" glyph.) The d and b characters are there just to indicate the overall size of the composite symbol.

\documentclass{article}
\usepackage{amssymb} % for "\square" macro
\newcommand{\qc}{%
\ooalign{$\square$\cr\kern0.21em\raise0.28ex\hbox{s}}}
\begin{document}
\obeylines % just for this example
\footnotesize d\qc b
\small      d\qc b
\normalsize d\qc b
\large      d\qc b
\Large      d\qc b
\end{document}

• Just saw your comment. To use the new composite symbol as a replacement QED-symbol, load (say) the amsmath package and issue the instruction \renewcommand\qedsymbol{\qc}.
– Mico
Mar 12, 2017 at 17:10
• I'm using it with \begin{proof}\renewcommand{\qedsymbol}{\qc} Mar 12, 2017 at 17:12
• @AthenaWidget -- That'll certainly work as well; it'll keep the redefinition of the QED symbol "local" to the given proof environment.
– Mico
Mar 12, 2017 at 17:17

I assume you want a math symbol. If not, it would be easy to adjust the macro.

\documentclass{article}
\usepackage{amssymb}

\makeatletter
\DeclareRobustCommand\qc{%
\mathrel{% <-- or \mathbin, or ...
\vphantom{\square}%
\mathpalette\aw@qc\relax
}%
}
\newcommand{\aw@qc}[2]{%
\sbox\z@{$#1\square$}%
\sbox\tw@{$#1\mathrm{s}$}%
\dimen@=.5\dimexpr\ht\z@-\ht\tw@\relax
\ooalign{%
$\m@th#1\square$\cr
\hidewidth\raise\dimen@\box\tw@\hidewidth\cr
}%
}
\makeatother
\begin{document}

\footnotesize $d\qc b$

\small      $d\qc b$

\normalsize $d\qc b_{\qc}$

\large      $d\qc b$

\Large      $d\qc b$

\end{document}


For each math style, the amount of raising is computed as half the height of the square minus the height of ‘s’. With \ooalign we get the superposition.

If you want a substitute for the QED marker in amsthm, here's the code. The twocolumn option is just for making a smaller picture.

\documentclass[twocolumn]{article}
\usepackage{amssymb,amsthm}

\makeatletter
\newcommand{\qc}{%
\begingroup
\vphantom{\openbox}%
\sbox\z@{\openbox}%
\sbox\tw@{$\mathrm{s}$}%
\dimen@=.5\dimexpr\ht\z@-\ht\tw@\relax
\ooalign{%
\box\z@\cr
\hidewidth\raise\dimen@\box\tw@\hidewidth\cr
}%
\endgroup
}
\makeatother

\begin{document}

\begin{proof}\renewcommand{\qedsymbol}{\qc}
Some proof with the modified symbol at the end of the line.
\end{proof}

\begin{proof}
Some proof with the standard symbol at the end of the line.
\end{proof}

\end{document}