How do I insert a custom (constant) text before all item descriptions in a description list?
For instance, I want to create something like this:
Question 1: My question
Answer: My answer
Generated from a code like:
\begin{questionsandanswers}
\item[My question] My Answer
\end{questionsandanswers}
I'm using enumitem to edit some parts of the description list. My code until now follows:
\usepackage{enumitem}
\newcounter{descriptcount}
\newlist{enumdescript}{description}{2}
\setlist[enumdescript,1]{%
before={\setcounter{descriptcount}{0}%
\renewcommand*\thedescriptcount{\arabic{descriptcount}}}
,font=\textbf{\stepcounter{descriptcount}Question \thedescriptcount:~} \normalfont
}
\setlist[enumdescript,2]{%
before={\setcounter{descriptcount}{0}%
\renewcommand*\thedescriptcount{\alph{descriptcount}}}
,font=\textbf{\stepcounter{descriptcount}Question \thedescriptcount:~} \normalfont
}
\newenvironment{questionsandanswers}{\begin{enumdescript}[style=nextline,labelindent=\parindent,leftmargin=\parindent]}{\end{enumdescript}}
With such a code a get something like:
Question 1: My question
My answer
But I can't find how to put the "Answer" word before the actual answer. Also, follows a minimal working example:
\documentclass{article}[12pt,a4paper]
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\newcounter{descriptcount}
\newlist{enumdescript}{description}{2}
\setlist[enumdescript,1]{%
before={\setcounter{descriptcount}{0}%
\renewcommand*\thedescriptcount{\arabic{descriptcount}}}
,font= \textbf{\stepcounter{descriptcount}Question \thedescriptcount.~} \normalfont
}
\setlist[enumdescript,2]{%
before={\setcounter{descriptcount}{0}%
\renewcommand*\thedescriptcount{\alph{descriptcount}}}
,font= \textbf{\stepcounter{descriptcount}Question \thedescriptcount.~} \normalfont
}
\newenvironment{questionsandanswers}{\begin{enumdescript}[style=nextline,labelindent=\parindent,leftmargin=\parindent]}{\end{enumdescript}}
\begin{document}
Desired syntax:
\begin{questionsandanswers}
\item[My question] My answer
\end{questionsandanswers}
Desired result:
\begin{questionsandanswers}
\item[My question] \textbf{Answer:} My answer
\end{questionsandanswers}
\end{document}
\documentclass{...}
and ending with\end{document}
.\begin{questionsandanswers} \newquestion This is the question? \newanswer This is the answer. \newquestion This is another question? \newanswer This is another answer. \end{questionsandanswers}
, or even simplify it to\question
and\answer
. Are you open to such a suggestion?\newanswer
with every\newquestion
, thereby not "let[ting] go of the need for an actual answer".