[Tex/LaTex] Beginner template

templates

I just downloaded TexWorks using MikTex. I am trying to write my math homework in Latex form but I am having difficulty getting the correct template. My template looks like this:

\title{}
\date{\today}

\documentclass[12pt]{article}

\begin{document}
\maketitle


\section{}


\end{document}

How can I insert my questions in LaTex form? For example, right after the date I want to have "{question 1(in bold)} … {answer to question 1} … {question 2(in bold)} … {answer to question 2}" so on and so forth to the very last question?

Best Answer

This can be done in several ways. Here's one possibility using theorem-like structures defined with the help of the amsthm package:

\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{etoolbox}
\usepackage{lipsum}

\theoremstyle{definition}
\newtheorem{que}{Question}
\newtheorem{ans}[que]{Answer to question}

\BeforeBeginEnvironment{ans}{\addtocounter{que}{-1}}
\title{Assignment}
\author{The Author}
\date{\today}

\begin{document}

\maketitle

\begin{que}
\lipsum[4]
\end{que}

\begin{ans}
\lipsum[4]
\end{ans}

\begin{que}
\lipsum[4]
\end{que}

\begin{ans}
\lipsum[4]
\end{ans}

\end{document}

enter image description here

In the previous solution I made the assumption that each question was immediately followed by its answer; a solution with more freedom might be:

\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{refcount}
\usepackage{lipsum}

\theoremstyle{definition}
\newtheorem{que}{Question}
\newtheorem{answ}{Answer to question}

\newenvironment{ans}[1]
  {\setcounterref{answ}{#1}\addtocounter{answ}{-1}\begin{answ}}
  {\end{answ}}

\title{Assignment}
\author{The Author}
\date{\today}

\begin{document}

\maketitle

\begin{que}
\label{que:foo}
\lipsum[4]
\end{que}

\begin{que}
\label{que:bar}
\lipsum[4]
\end{que}

\begin{ans}{que:bar}
\lipsum[4]
\end{ans}

\begin{ans}{que:foo}
\lipsum[4]
\end{ans}

\end{document}

enter image description here

In this approach, you label each question (using the standard \label command), and then use the string used for the label as a mandatory argument for the ans environment.