LaTeX forum ⇒ 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.
shashwatss
Posts: 1
Joined: Thu Apr 26, 2018 10:24 am

Display something in front of an environment variable already declared

Postby shashwatss » Thu Apr 26, 2018 10:33 am

hi,
i have set the environment variables for use in document. It is as follows:
  1. \newcommand{\homeworkProblemName}{}
  2. <span style="font-weight: bold">\newenvironment{homeworkProblem}[1][Question \arabic{homeworkProblemCounter}]{ % Makes a new environment called homeworkProblem which takes 1 argument (custom name) but the default is "Problem #"</span>
  3. \stepcounter{homeworkProblemCounter} % Increase counter for number of problems
  4. \renewcommand{\homeworkProblemName}{#1} % Assign \homeworkProblemName the name of the problem
  5. \section{\homeworkProblemName} % Make a section in the document with the custom problem count
  6. \enterProblemHeader{\homeworkProblemName} % Header and footer within the environment
  7. }{
  8. \exitProblemHeader{\homeworkProblemName} % Header and footer after the environment
  9. }
  10.  
  11.  
  12.  
  13. %----------ANSWER SECTION----
  14. \newcommand{\problemAnswer}[1]{ % Defines the problem answer command with the content as the only argument
  15. \noindent\framebox[\columnwidth][c]{\begin{minipage}{0.98\columnwidth}#1\end{minipage}} % Makes the box around the problem answer and puts the content inside
  16. }
  17.  
  18. \newcommand{\homeworkSectionName}{}
  19. \newenvironment{homeworkSection}[1]{ % New environment for sections within homework problems, takes 1 argument - the name of the section
  20. \renewcommand{\homeworkSectionName}{#1} % Assign \homeworkSectionName to the name of the section from the environment argument
  21. \subsection{\homeworkSectionName} % Make a subsection with the custom name of the subsection
  22. \enterProblemHeader{\homeworkProblemName\ [\homeworkSectionName]} % Header and footer within the environment
  23. }{
  24. \enterProblemHeader{\homeworkProblemName} % Header and footer after the environment
  25. }


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:-
  1. <span style="font-weight: bold">\begin{homeworkProblem}</span>
  2. %<span style="font-weight: bold">WHAT SHOULD I CHANGE IN THE ABOVE BOLD FACED TEXT TO ACHIEVE THE REQUIRED OUTPUT?</span>
  3.  
  4. %Question
  5.  
  6. \vspace{10pt}
  7. %Answer
  8. \problemAnswer
  9. {
  10. \begin{center}
  11. \includegraphics[width=0.75\columnwidth]{pic1} % Example image
  12. \end{center}
  13.  
  14. \lipsum[2]
  15. }
  16. \end{homeworkProblem}

Kindly help. Thank you :)
Regards,
Shashwat

User avatar
Johannes_B
Site Moderator
Posts: 3953
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun Apr 29, 2018 7:49 am

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.


Return to “Document Classes”

Who is online

Users browsing this forum: No registered users and 2 guests