General ⇒ Environment to list content
Environment to list content
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
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Re: Environment to list content
and the format for the arguments in the final document? Please describe the desired final layout for "Question", "Author", "Title", "Tag" and "Answer".
Environment to list content
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
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}
Re: Environment to list content
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Environment to list content
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10