i have set the environment variables for use in document. It is as follows:
Code: Select all
\newcommand{\homeworkProblemName}{}
[b]\newenvironment{homeworkProblem}[1][Question \arabic{homeworkProblemCounter}]{ % Makes a new environment called homeworkProblem which takes 1 argument (custom name) but the default is "Problem #"[/b]
\stepcounter{homeworkProblemCounter} % Increase counter for number of problems
\renewcommand{\homeworkProblemName}{#1} % Assign \homeworkProblemName the name of the problem
\section{\homeworkProblemName} % Make a section in the document with the custom problem count
\enterProblemHeader{\homeworkProblemName} % Header and footer within the environment
}{
\exitProblemHeader{\homeworkProblemName} % Header and footer after the environment
}
%----------ANSWER SECTION----
\newcommand{\problemAnswer}[1]{ % Defines the problem answer command with the content as the only argument
\noindent\framebox[\columnwidth][c]{\begin{minipage}{0.98\columnwidth}#1\end{minipage}} % Makes the box around the problem answer and puts the content inside
}
\newcommand{\homeworkSectionName}{}
\newenvironment{homeworkSection}[1]{ % New environment for sections within homework problems, takes 1 argument - the name of the section
\renewcommand{\homeworkSectionName}{#1} % Assign \homeworkSectionName to the name of the section from the environment argument
\subsection{\homeworkSectionName} % Make a subsection with the custom name of the subsection
\enterProblemHeader{\homeworkProblemName\ [\homeworkSectionName]} % Header and footer within the environment
}{
\enterProblemHeader{\homeworkProblemName} % Header and footer after the environment
}
My code for displaying the question and answers is as follows:-
Code: Select all
[b]\begin{homeworkProblem}[/b]
%[b]WHAT SHOULD I CHANGE IN THE ABOVE BOLD FACED TEXT TO ACHIEVE THE REQUIRED OUTPUT?[/b]
%Question
\vspace{10pt}
%Answer
\problemAnswer
{
\begin{center}
\includegraphics[width=0.75\columnwidth]{pic1} % Example image
\end{center}
\lipsum[2]
}
\end{homeworkProblem}

Regards,
Shashwat