Comments (1)
With the default setting exercise/template=default
, exercise title is typeset by \subsection*{<title>}
, which takes care of vertical spacing between following list (like enumerate
) automatically, through \@afterheading
.
With exercise/template=centered
, the same exercise title is now typeset manually, by \hfil\textbf{<title>}...\hfil\par\noindent
. This time the vertical space \topsep
inserted by a list environment (between it and the previous text) is not ignored automatically any more.
Implementations of exercise templates default
and centered
Lines 5509 to 5533 in 06e3dba
xsim/code/xsim.style.layouts.code.tex
Lines 95 to 115 in 06e3dba
Adding back \@afterheading
(manually or by patching the centered
template) solves the problem, partially. Note with exercise/template=centered
, if exercise property points
is given for an exercise starting with a list environment, the value of points
will be typeset in its own paragraph, as a marginal note. You may need to manually adjust the vertical spacing.
\documentclass{article}
\usepackage{lipsum}
% to show distances between baseline heights
\usepackage{lineno}
\renewcommand{\thelinenumber}{\arabic{linenumber}\rlap{\rule{.4pt}{11pt}}}
\linenumbers
%\usepackage{cmbright}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[clear-aux]{xsim}
\xsimsetup{
load-style=layouts,
exercise/template=centered,
}
\makeatletter
% cheat `xsim` as if `centered` template is undefined
\ExpandArgs{cc}\relax {cs_undefine:N} {l__xsim_template_begin_centered_setup_tl}
\ExpandArgs{cc}\relax {cs_undefine:N} {l__xsim_template_end_centered_setup_tl}
\DeclareExerciseEnvironmentTemplate{centered}
{%
\par\vspace{\baselineskip}
\Needspace*{2\baselineskip}
\noindent
\hfil\textbf{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}}%
\GetExercisePropertyT{subtitle}{ \textit{#1}}\hfil
\par\noindent\@afterheading % <<< changed
\IfInsideSolutionF{%
\GetExercisePropertyT{points}{%
\marginpar{%
\printgoal{\PropertyValue}%
\GetExercisePropertyT{bonus-points}{+\printgoal{\PropertyValue}}%
\,\IfExerciseGoalSingularTF{points}
{\XSIMtranslate{point}}
{\XSIMtranslate{points}}%
}%
}%
}%
}
{}
\makeatother
\begin{document}
\begin{exercise}[subtitle={no points + plain text}]
Normal distance between header and text!
\end{exercise}
\begin{exercise}[subtitle={no points + list}]
\begin{enumerate}
\item Greater distance between header and text!
\end{enumerate}
\end{exercise}
\begin{exercise}[points=2, subtitle={points + plain text}]
Normal distance between header and text!
\end{exercise}
\begin{exercise}[points=3, subtitle={points + list}]
\begin{enumerate}
\item Greater distance between header and text!
\end{enumerate}
\end{exercise}
\begin{exercise}[points=4, subtitle={points + list + manual adjustment}]
\vspace{-\baselineskip}
\begin{enumerate}
\item Greater distance between header and text!
\end{enumerate}
\end{exercise}
\section*{Emulation}
\subsection*{EnvironmentTemplate=default}
\lipsum[2][1]
\subsection*{EnvironmentTemplate=default}
\begin{enumerate}
\item \lipsum[2][1]
\end{enumerate}
\hfil\textbf{EnvironmentTemplate=centered}\hfil \par
\lipsum[2][1]
\hfil\textbf{EnvironmentTemplate=centered}\hfil \par
\begin{enumerate}
\item \lipsum[2][1]
\end{enumerate}
\hfil\textbf{EnvironmentTemplate=centered, patched}\hfil \par
\UseName{@afterheading}%
\begin{enumerate}
\item \lipsum[2][1]
\end{enumerate}
\end{document}
from xsim.
Related Issues (20)
- Improve doc for `\UseExerciseTemplate` HOT 3
- \numberofexercise with space after HOT 1
- Custom grading table template not working HOT 3
- global option print-solutions HOT 1
- Solutions not printed HOT 2
- Allow printcollection to filter by tags
- match-all and match-any option for collection may be redundant.
- xsim, babel and tikz; problem with quotation marks
- Request: pointssum of an exercise behind the last line
- Possible Bug when combining a tabular and an exercise environment HOT 3
- double vertical line in array HOT 1
- Cloze-Tests, blanks not filled with solution/print = true HOT 1
- Wrong documentation for `AddtoExerciseTypeGoal` and `AddtoExerciseTypeGoalPrint`
- Points question xsim package precision decimal HOT 2
- solution HOT 4
- Problem with two ExerciseType HOT 3
- Wording of warning message HOT 4
- Printcollection outputs questions without question number HOT 1
- exercise property "solution" does not work as expected HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xsim.