I would like to use an “environment” or some form of command that would achieve the following:
There would be 5 fields:
• Question (could be a paragraph or more text with formulas, tables,…)
• Author (less than 128 characters)
• Title (less than 128 characters)
• Tag (open of closed, so binary)
• Optional field for answer (could be a paragraph or more,…)
Then I would be able to call this environment anywhere in my documents.
In addition I’d like to be able to make a list of (open) questions with titles like a list of figures for instance.
Any ideas where I could find something like that? Or how to create it?
Thanks
General ⇒ Environment to list content
Environment to list content
Last edited by jc_tex on Sun Sep 12, 2010 10:52 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

Re: Environment to list content
Hi,
and the format for the arguments in the final document? Please describe the desired final layout for "Question", "Author", "Title", "Tag" and "Answer".
and the format for the arguments in the final document? Please describe the desired final layout for "Question", "Author", "Title", "Tag" and "Answer".
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Environment to list content
Hi,
It would look like
Question 2.3. -- Short title (Closed) %in bold, and that would be the third question in chap 2.
This is the text for the main question.
My name, Sept 1st 2010
Answer 2.3.
This is the answer of the question.
Other name, Sept 12th 2010
And then I'd like the ability to list all (open or not) question titles at the beginning of the document.
Thanks
It would look like
Question 2.3. -- Short title (Closed) %in bold, and that would be the third question in chap 2.
This is the text for the main question.
My name, Sept 1st 2010
Answer 2.3.
This is the answer of the question.
Other name, Sept 12th 2010
And then I'd like the ability to list all (open or not) question titles at the beginning of the document.
Thanks
Environment to list content
I think it's better to have two environments: one for the questions and the other one for the answers. The following code will give you some ideas:
Of course, feel free to adapt my example to meet your needs.
Code: Select all
\documentclass{book}
\usepackage{tocloft}
\newcommand{\listquestionname}{List of Questions}
\newlistof[chapter]{question}{qst}{\listquestionname}
\newsavebox\mybox
\newenvironment{Myquestion}[3]
{\refstepcounter{question}%
\addcontentsline{qst}{question}{\protect\numberline{\thequestion} #1}
\medskip\noindent{\bfseries Question~\thequestion--#1 (#2)}\\\textit{#3}\\%
}
{\par}
\newenvironment{Myanswer}[1]
{\sbox\mybox{\textit{#1}}
\par\noindent{\bfseries Answer~\thequestion}\\%
}
{\\\usebox\mybox\par}
\begin{document}
\listofquestion
\chapter{Test chapter}
\begin{Myquestion}{Short title}{Closed}{My name, Sept. 1st 2010}
The text of the question goes here.
\end{Myquestion}
\begin{Myanswer}{Other name, Sept. 12th 2010}
The text of the answer goes here.
\end{Myanswer}
\begin{Myquestion}{Short title}{Open}{My name, Sept. 1st 2010}
The text of the question goes here.
\end{Myquestion}
\chapter{Test chapter two}
\begin{Myquestion}{Short title}{Open}{My name, Sept. 2nd 2010}
The text of the question goes here.
\end{Myquestion}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Re: Environment to list content
Thank you very much gmedina, that's what I needed.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Environment to list content
Now that the problem is solved, please be so kind and mark the topic accordingly as clearly written in Section 3 of the Board Rules (to be read before posting).
Best regards and welcome to the board
Thorsten
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10