
我想列印(轉儲)書末問題的答案。如果我只是使用,\printsolutions
我會在新行中得到每個解決方案(作為一個新段落)。
我需要將它們放在同一行(只有數字,沒有名稱),如下所示:
1)索爾一。2)索爾二。3)... ETC。
有沒有辦法/解決方法來實現這一點?
如果是,有沒有辦法自動將節/小節名稱包含在清單中(在同一行)?喜歡
第 1 節。 1)索爾一。2)索爾二。第二小節。 1)索爾一。2)索爾二。第 2 節第 1 款 1)索爾一...
編輯:
在 cgnieder 編輯之後,我試圖找到一種方法來避免手動標記和 '\nameref'。我想出了一些辦法,但它沒有按預期工作——“printsolutions”為各部分提供了相同的名稱。另請參閱內嵌文本和評論。幫助!
\documentclass{scrartcl}
\usepackage{exsheets}
\setlength{\parindent}{0pt}
\DeclareQuestionProperty{section-title}
\SetupExSheets{counter-within=section ,
headings=inline-nr ,
counter-format=qu)}
\newcommand{\lsection}[1]{
\def\secName{#1}
\section{#1}
}
\SetupExSheets{section-hook = \noindent\bfseries
Section \GetQuestionProperty{section-title}{\CurrentQuestionID}
\space}
\begin{document}
\lsection{One}
\begin{question}
\SetQuestionProperties{section-title= \secName }
foo
\end{question}
\begin{solution}
foo
\end{solution}
\begin{question}
\SetQuestionProperties{section-title= \secName }
bar
\end{question}
\begin{solution}
bar
\end{solution}
Solutions for section "\secName" are: \printsolutions[section]\\ % OK
ALL the solutions until here are: \printsolutions % OK
\lsection{Two}
\begin{question}
\SetQuestionProperties{section-title= \secName }
baz
\end{question}
\begin{solution}
baz
\end{solution}
\begin{question}
\SetQuestionProperties{section-title= \secName }
foobar
\end{question}
\begin{solution}
foobar
\end{solution}
Solutions for section "\secName" are: \printsolutions[section]\\ % OK
ALL the solutions at this point are wrong, the 1st section name is "Two" instead of "One": \printsolutions % WRONG!!
\lsection{Answers} %changing '\lsection' to '\section' makes all the section names as "Two"
This is the output of 'printsolutions' wrongly showing the same section name throuhout (the last name used):
\printsolutions
\end{document}
答案1
您想要的清單可以使用inline-nr
標題實例並設定\exsheets_par:
等於\scan_stop:
。第二點防止exsheets
a) 在其環境後面插入 a\par
和 b) 在 後面插入垂直空格\par
。這是一個未記錄的功能,但為此目的內建了額外功能。我將為它添加一個官方用戶介面。
不幸的是,目前還沒有辦法自動取得完整的列表,並在適當的位置插入章節標題。但是您可以將exsheets
'\exlabel
機制與nameref
半自動解決方案一起使用:
\documentclass{scrartcl}
\usepackage[load-headings]{exsheets}
\SetupExSheets{counter-within=section}
\usepackage{nameref}
% place \label and \exlabel simultaneously:
\newcommand*\mylabel[1]{\label{#1}\exlabel{#1}}
\begin{document}
\section{One}\mylabel{sec:foo}
\begin{question}
foo
\end{question}
\begin{solution}
foo
\end{solution}
\begin{question}
bar
\end{question}
\begin{solution}
bar
\end{solution}
\section{Two}\mylabel{sec:bar}
\begin{question}
baz
\end{question}
\begin{solution}
baz
\end{solution}
\begin{question}
foobar
\end{question}
\begin{solution}
foobar
\end{solution}
\section{Solutions}
\ExplSyntaxOn
\cs_set_eq:NN \exsheets_par: \scan_stop:
\ExplSyntaxOff
\SetupExSheets{headings=inline-nr,counter-format=qu)}
\textbf{Section \nameref{sec:foo}} \printsolutions[section={\S{sec:foo}}]
\textbf{Section \nameref{sec:bar}} \printsolutions[section={\S{sec:bar}}]
\end{document}
編輯
版本 0.13 (2014/05/11)exsheets
提供了選項section-hook
.與nameref
和 問題屬性結合使用時,可以透過以下方式使用它來實現相同的佈局:一呼叫\printsolutions
:
\documentclass{scrartcl}
\usepackage[load-headings]{exsheets}[2014/05/11]
\SetupExSheets{counter-within=section}
\DeclareQuestionProperty{section-title}
\usepackage{nameref}
\begin{document}
\section{One}\label{sec:foo}
\begin{question}
\SetQuestionProperties{section-title=\nameref{sec:foo}}
foo
\end{question}
\begin{solution}
foo
\end{solution}
\begin{question}
\SetQuestionProperties{section-title=\nameref{sec:foo}}
bar
\end{question}
\begin{solution}
bar
\end{solution}
\section{Two}\label{sec:bar}
\begin{question}
\SetQuestionProperties{section-title=\nameref{sec:bar}}
baz
\end{question}
\begin{solution}
baz
\end{solution}
\begin{question}
\SetQuestionProperties{section-title=\nameref{sec:bar}}
foobar
\end{question}
\begin{solution}
foobar
\end{solution}
\section{Solutions}
\SetupExSheets{
headings = inline-nr , % numbered and inline
counter-format = qu) , % numbers 1) 2) ...
section-hook = % code to be added before solutions of a new section
% are printed
% \par begin a new paragraph for a new section
\noindent\bfseries
Section \GetQuestionProperty{section-title}{\CurrentQuestionID}%
\space
}
\printsolutions
\end{document}