我正在嘗試使用 probsoln 和列表包進行計算機科學練習,但當問題放在單獨的文件中時,這些包似乎不相容。任何幫助將非常感激。
在文件中定義問題:
\documentclass{report}
\usepackage{probsoln,listings}
\begin{document}
\begin{onlyproblem}[fragile]
\lstset{language=Pascal}
\begin{lstlisting}
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write('Case insensitive');
WritE('Pascal keywords.');
\end{lstlisting}
\end{onlyproblem}
\end{document}
效果很好,但是當我將問題和主文檔分開時,程式碼無法編譯。
例如,編譯testPsLstLoad.tex
\documentclass{report}
\usepackage{probsoln,listings}
\begin{document}
\loadallproblems{testProblem}
\useproblem{program}
\end{document}
與 testProblem.tex
\begin{defproblem}{program}
\begin{onlyproblem}[fragile]
\lstset{language=Pascal}
\begin{lstlisting}
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write('Case insensitive');
WritE('Pascal keywords.');
\end{lstlisting}
\end{onlyproblem}
\end{defproblem}
給出:
pdflatex testPsLstLoad.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./testPsLstLoad.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-08-07>
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/report.cls
Document Class: report 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2020/texmf-dist/tex/latex/probsoln/probsoln.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/ifthen.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/local/texlive/2020/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/local/texlive/2020/texmf-dist/tex/generic/xkeyval/xkvutils.tex
(/usr/local/texlive/2020/texmf-dist/tex/generic/xkeyval/keyval.tex)))))
(/usr/local/texlive/2020/texmf-dist/tex/latex/listings/listings.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/listings/lstmisc.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/listings/listings.cfg))
(/usr/local/texlive/2020/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def)
(./testPsLstLoad.aux) (./testProblem.tex) (./testPsLstLoad.vrb
(/usr/local/texlive/2020/texmf-dist/tex/latex/listings/lstlang1.sty)
Package Listings Warning: Text dropped after begin of listing on input line 1.
)
! LaTeX Error: \begin{lstlisting} on input line 1 ended by \end{onlyproblem}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.6 \useproblem{program}
?
謝謝,喬恩
答案1
我知道,所以請原諒......:)
我認為,我發現了清單和問題之間的另一個不相容性。
我使用模板“Orange Book”,清單中我有“TeX 容量超出,抱歉[參數堆疊大小=10000]”。
沒有我的文檔可以完美編譯...
\usepackage{bbding} \usepackage{amsmath} \usepackage{probsoln} \usepackage{enumitem}%,hyperref} \usepackage{nccmath} % 用來對齊標籤內的ceqn 中心方程式\usepackage{pdfpages} \package{caption} \package{caption} \package{pdfpages} \package{caption} \package{pdfpages} \package{caption} \package{pdfpages} \package{caption} usepackage{ multicol} % 多冒號文字 \usepackage{wrapfig} % 在 multicol 中繪製表格和圖形 \usepackage{multirow} % 繪製表格 \usepackage{epigraph} \usepackage{longtable} %\package{listings}
此致