Document ClassesDisplay something in front of an environment variable already declared

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
shashwatss
Posts: 1
Joined: Thu Apr 26, 2018 10:24 am

Display something in front of an environment variable already declared

Post by shashwatss »

hi,
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
}
I would like to display the output as "Question 1 - Circuit Input", for next question it should be "Question 2 - Cicuit Analysis".

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}
Kindly help. Thank you :)
Regards,
Shashwat

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Display something in front of an environment variable already declared

Post by Johannes_B »

Can you expand your snippets into a compilable document? Right now, the snippets are less than helpful, also, there are css things intermixed.

A document we can compile is almost always a guaranty for an answer.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply