3

I'm trying to create a dynamic numbering system for a survey, with questions that I can also reference.

I would like to see

Q1. What is your age?

but playing around with \newtheorem all I can get is

Q 1. What is your age?

I have not been able to figure how to alter \newtheoremstyle to remove the space between "Q" and the number.

\documentclass{article}
\usepackage{amsthm}

\newtheorem{question}{Q}

\begin{document}

\begin{question}
What is your age?

\label{q:age}

\end{question}

\end{document}
5

With thmtools you can update the way your theorem displays by creating a custom layout:

enter image description here

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}

\declaretheoremstyle[
  bodyfont=\normalfont\itshape,
  headformat=\NAME\NUMBER  
]{nospacetheorem}
\declaretheorem[style=nospacetheorem,name=Q]{question}

\begin{document}

\begin{question}
What is your age?
\end{question}

\end{document}

Of course, there is no real need for a theorem here:

\documentclass{article}

\newcounter{question}
\newenvironment{question}
  {\par\noindent
   \refstepcounter{question}%
   \textbf{Q\thequestion.}~\itshape\ignorespaces}
  {\par\ignorespacesafterend}

\begin{document}

\begin{question}
What is your age?
\end{question}

\end{document}
4
\newtheorem{question}{Q\ignorespaces}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.