使“exercises”包与“kaobook”兼容

使“exercises”包与“kaobook”兼容

在这个问题中,我尝试将包exercisekaobook类一起使用。

exam最初,我计划将类与类一起使用kaobook,直到我注意到它如何改变页面的边距。我发布了这个问题并得到了一些很好的反馈,建议我停止使用考试包,而是尝试另一个类似的包exercise

接下来我发现这个问题和答案我真的很喜欢练习和解决方案的外观。我尝试在 kaobook 类中使用它,但它产生了一些新问题。现在我在应该显示子部分(罗马数字)的地方打印了“tsk[r]”。

在此处输入图片描述

在此处输入图片描述

以下是 MWE:

\documentclass[
    fontsize=10pt, % Base font size
    twoside=false, % Use different layouts for even and odd pages (in particular, if twoside=true, the margin column will be always on the outside)
    %open=any, % If twoside=true, uncomment this to force new chapters to start on any page, not only on right (odd) pages
    %chapterprefix=true, % Uncomment to use the word "Chapter" before chapter numbers everywhere they appear
    %chapterentrydots=true, % Uncomment to output dots from the chapter name to the page number in the table of contents
    numbers=noenddot, % Comment to output dots after chapter numbers; the most common values for this option are: enddot, noenddot and auto (see the KOMAScript documentation for an in-depth explanation)
    %draft=true, % If uncommented, rulers will be added in the header and footer
    %overfullrule=true, % If uncommented, overly long lines will be marked by a black box; useful for correcting spacing problems
]{kaobook}

% Set the language
\usepackage[english]{babel} % Load characters and hyphenation
\usepackage[english=british]{csquotes} % English quotes

% Load mathematical packages for theorems and related environments. NOTE: choose only one between 'mdftheorems' and 'plaintheorems'.
\usepackage{styles/mdftheorems}
%\usepackage{styles/plaintheorems}

%https://tex.stackexchange.com/questions/369265/math-book-how-to-write-exercise-and-answers
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{ifthen}
\newboolean{firstanswerofthechapter}  
\usepackage{xcolor}
\colorlet{lightcyan}{cyan!40!white}
\usepackage{chngcntr}
\usepackage{stackengine}
\usepackage{tasks}
\newlength{\longestlabel}
\settowidth{\longestlabel}{\bfseries viii.}
\settasks{counter-format={tsk[r].}, label-format={\bfseries}, label-width=\longestlabel,
    item-indent=0pt, label-offset=2pt, column-sep={10pt}}
\usepackage[lastexercise,answerdelayed]{exercise}
\counterwithin{Exercise}{chapter}
\counterwithin{Answer}{chapter}
\renewcounter{Exercise}[chapter]
\newcommand{\QuestionNB}{\bfseries\arabic{Question}.\ }
\renewcommand{\ExerciseName}{EXERCISES}
\renewcommand{\ExerciseHeader}{\noindent\def\stackalignment{l}% code from https://tex.stackexchange.com/a/195118/101651
    \stackunder[0pt]{\colorbox{cyan}{\textcolor{white}{\textbf{\LARGE\ExerciseHeaderNB\;\large\ExerciseName}}}}{\textcolor{lightcyan}{\rule{\linewidth}{2pt}}}\medskip}
\renewcommand{\AnswerName}{Exercises}
\renewcommand{\AnswerHeader}{\ifthenelse{\boolean{firstanswerofthechapter}}%
    {\bigskip\noindent\textcolor{cyan}{\textbf{CHAPTER \thechapter}}\newline\newline%
        \noindent\bfseries\emph{\textcolor{cyan}{\AnswerName\ \ExerciseHeaderNB, page %
                \pageref{\AnswerRef}}}\smallskip}
    {\noindent\bfseries\emph{\textcolor{cyan}{\AnswerName\ \ExerciseHeaderNB, page \pageref{\AnswerRef}}}\smallskip}}
\setlength{\QuestionIndent}{16pt}

\usepackage{gensymb} %for degree symbol
\usepackage{tipx} %For \textturntwo and \textturnthree symbols

\begin{document}
\chapter{First}

    \begin{Exercise}\label{EX11}
        \vspace{-\baselineskip}% <-- You don't need this line of code if there's some text here
        \Question In problem \ref{EX11-1-i}-\ref{EX11-1-iii}, determine whether the given differential equation is separable  
        \begin{tasks}(2)
            \task\label{EX11-1-i} $\frac{dy}{dx}-\sin{(x+y)}=0$     
            \task $\frac{dy}{dx}=4y^2-3y+1$ 
            \task\label{EX11-1-iii} $\frac{ds}{dt}=t\ln{(s^{2t})}+8t^2$ 
        \end{tasks}
        \Question In problem \ref{EX11-2-iv}-\ref{EX11-2-viii}, solve the equation 
        \begin{tasks}[resume=true](2)
            \task\label{EX11-2-iv} $\frac{dx}{dt}=3xt^2$
            \task $y^{-1}dy+ye^{\cos{x}}\sin{x}dx=0$
            \task $(x+xy^2)dx+ye^{\cos{x}}\sin{x}dx=0$
            \task\label{EX11-2-viii} $\frac{dy}{dt} = \frac{y}{t+1} + 4t^2 +  4t$, $\quad$ $y(1) = 10$
        \end{tasks}
    \end{Exercise}
    \setboolean{firstanswerofthechapter}{true}
    \begin{multicols}{2}
        \begin{Answer}[ref={EX11}]
            \Question 
            \begin{tasks}
                \task This is a solution of Ex 1
                \task This is a solution of Ex 2 
                \task This is a solution of Ex 3 
            \end{tasks} 
            \Question 
            \begin{tasks}[resume=true]
                \task This is a solution of Ex 4
                \task This is a solution of Ex 5 
                \task This is a solution of Ex 6 
                \task This is a solution of Ex 7 
            \end{tasks} 
        \end{Answer}
    \end{multicols}
    \setboolean{firstanswerofthechapter}{false}

    \begin{Exercise}\label{EX12}
        Another exercise. 
        \Question If you don't need a horizontal list, you can simply use \verb|\Question|
    \end{Exercise}
    \begin{multicols}{2}
        \begin{Answer}[ref={EX12}]
            \Question This is a solution of Ex 1
        \end{Answer}
    \end{multicols}

    \chapter{Second}

    \begin{Exercise}\label{EX21}
        \vspace{-\baselineskip}% <-- You don't need this line of code if there's some text here
        \Question Eight systems of differential equations and five direction fields are given below.  Determine the system that corresponds to each direction field and sketch the solution curves that correspond to the initial conditions $(x_0, y_0) = (0,1)$ and $(x_0, y_0) = (1,-1)$.
        \begin{tasks}(3)
            \task $\begin{aligned}
            \frac{dx}{dt} & = -x \\     
            \frac{dy}{dt} & = y-1
            \end{aligned}$
            \task $\begin{aligned}
            \frac{dx}{dt} & = x^2 - 1 \\        
            \frac{dy}{dt} & = y
            \end{aligned}$
            \task $\begin{aligned}
            \frac{dx}{dt} & = x+2y \\
            \frac{dy}{dt} & = -y
            \end{aligned}$
            \task $\begin{aligned}
            \frac{dx}{dt} & = 2x \\
            \frac{dy}{dt} & =  y
            \end{aligned}$
            \task $\begin{aligned}
            \frac{dx}{dt} & = x \\
            \frac{dy}{dt}  & = 2y
            \end{aligned}$ 
            \task$\begin{aligned}
            \frac{dx}{dt} & = x-1 \\
            \frac{dy}{dt} & = -y
            \end{aligned}$
            \task$\begin{aligned}
            \frac{dx}{dt} & = x^2-1 \\
            \frac{dy}{dt} & = -y
            \end{aligned}$        
            \task $\begin{aligned}
            \frac{dx}{dt} & = x- 2y \\
            \frac{dy}{dt} & =  -y
            \end{aligned}$
        \end{tasks}
    \end{Exercise}
    \setboolean{firstanswerofthechapter}{true}
    \begin{multicols}{2}
        \begin{Answer}[ref={EX21}]
            \Question 
            \begin{tasks}
                \task This is a solution of Ex 1
                \task This is a solution of Ex 2 
                \task This is a solution of Ex 3 
                \task This is a solution of Ex 4 
                \task This is a solution of Ex 5 
                \task This is a solution of Ex 6 
                \task This is a solution of Ex 7 
                \task This is a solution of Ex 8 
            \end{tasks}
        \end{Answer}
    \end{multicols}
    \setboolean{firstanswerofthechapter}{false}
    \newpage        
    \begin{Exercise}\label{EX22}
        Since these are systems, maybe it's better to put the \verb|aligned| enviroment within  \verb|\left\{| and \verb|\right.|: 
        \Question Eight systems of differential equations and five direction fields are given below.  Determine the system that corresponds to each direction field and sketch the solution curves that correspond to the initial conditions $(x_0, y_0) = (0,1)$ and $(x_0, y_0) = (1,-1)$.
        \begin{tasks}(3)
            \task $\left\{\begin{aligned}
            \frac{dx}{dt} & = -x \\     
            \frac{dy}{dt} & = y-1
            \end{aligned}\right.$
            \task $\left\{\begin{aligned}
            \frac{dx}{dt} & = x^2 - 1 \\        
            \frac{dy}{dt} & = y
            \end{aligned}\right.$
            \task $\left\{\begin{aligned}
            \frac{dx}{dt} & = x+2y \\
            \frac{dy}{dt} & = -y
            \end{aligned}\right.$
            \task $\left\{\begin{aligned}
            \frac{dx}{dt} & = 2x \\
            \frac{dy}{dt} & =  y
            \end{aligned}\right.$
            \task $\left\{\begin{aligned}
            \frac{dx}{dt} & = x \\
            \frac{dy}{dt}  & = 2y
            \end{aligned}\right.$ 
            \task$\left\{\begin{aligned}
            \frac{dx}{dt} & = x-1 \\
            \frac{dy}{dt} & = -y
            \end{aligned}\right.$
            \task $\left\{\begin{aligned}
            \frac{dx}{dt} & = x^2-1 \\
            \frac{dy}{dt} & = -y
            \end{aligned}\right.$        
            \task $\left\{\begin{aligned}
            \frac{dx}{dt} & = x- 2y \\
            \frac{dy}{dt} & =  -y
            \end{aligned}\right.$
        \end{tasks}
    \end{Exercise}
    \begin{multicols}{2}
        \begin{Answer}[ref={EX22}]
            \Question 
            \begin{tasks}
                \task This is a solution of Ex 1
                \task This is a solution of Ex 2 
                \task This is a solution of Ex 3 
                \task This is a solution of Ex 4 
                \task This is a solution of Ex 5 
                \task This is a solution of Ex 6 
                \task This is a solution of Ex 7 
                \task This is a solution of Ex 8 
            \end{tasks}
        \end{Answer}
    \end{multicols}

    \chapter{Answer to all problems}

    \begin{multicols}{2}\raggedcolumns
        \shipoutAnswer
    \end{multicols}

\end{document}

这里还有直播Overleaf 链接向 MWE 显示错误。

在此先感谢您的帮助!


编辑:感谢 Willie Wong,计数器编号问题现已修复!现在唯一剩下的问题是“1.1 EXERCISES”标题的字体。“1.1”和“EXERCISES”之间的空格缺失,并且“EXERCISES”一词比应有的要大。

在此处输入图片描述

我发现评论\usepackage{tipx}可以解决这个问题,但这样就无法使用包中讨论的\textturntwo\textturnthree符号tipx这个问题和答案. 有什么解决方法吗?

答案1

  1. 根据 的最新版本tasks,该counter-format键已弃用。请改用罗马数字label=\roman*.
  2. 通常\;插入 0.2777em 的水平间距。tipx包加载tipa,用于排版语音字母。 的“功能”之一tipa是重新定义以创建特殊重音命令。您可以通过发出选项来\;关闭此功能。(所以。)这应该会恢复练习编号和练习标题之间的空间。safetipx\usepackage[safe]{tipx}
  3. 您不应该在同一组中发布两个字体大小开关。将它们分开。如果您{\LARGE\bfseries\ExerciseHeaderNB\hspace{0.2777em}}{\large\bfseries\ExerciseName}这样写,字体大小应该正确。

相关内容