Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with caption package #54

Open
dfcheca opened this issue Sep 27, 2023 · 2 comments
Open

Conflict with caption package #54

dfcheca opened this issue Sep 27, 2023 · 2 comments

Comments

@dfcheca
Copy link

dfcheca commented Sep 27, 2023

Hello. There is a minor conflict with the caption package. If this package is enabled, the last line of some mmaCell is not displayed. Any idea why this happens? Perhaps it's something trivial; I'm not familiar with the default options of the caption package, and I don't know why this conflict arises. I provide you a MRE to examine.

\documentclass[12pt]{article}
\usepackage{caption}
\usepackage{mmacells}

\begin{document}

\begin{mmaCell}[moredefined={SumFirst,SumFirstSquares,SumFirstCubes},morepattern={n_,n}]{Input}
  SumFirst[n_]:=Sum[i,\{i,1,n\}];
  SumFirstSquares[n_]:=Sum[\mmaSup{i}{2},\{i,1,n\}];
  SumFirstCubes[n_]:=Sum[\mmaSup{i}{3},\{i,1,n\}]
\end{mmaCell}

\end{document}
@dfcheca
Copy link
Author

dfcheca commented Sep 27, 2023

Update: For now, in the document I'm working on, the documentclass is scrbook. I was using the caption package to remove the colon next to the label of each figure, but I resolved it by using \renewcommand*{\captionformat}{\ } instead of caption package.

However, this solution doesn't work in the article class.

@jkuczm
Copy link
Owner

jkuczm commented Sep 30, 2023

Thanks for reporting it.

Under the hood mmacells is using fancyvrb with listings interface switched on. This seems to be a conflict of caption with fancyvrb and listings packages, since following has the same problem:

\documentclass[12pt]{article}
\usepackage{caption}
\usepackage{fancyvrb}
\usepackage{listings}

\begin{document}

\lstset{fancyvrb}
\begin{Verbatim}
first line
last line
\end{Verbatim}

\end{document}

pdf with listings+fancyvrb problem

caption package modifies some of listings functions responsible for captions. Among others it modifies \lst@MakeCaption and saves original version in \caption@ORI@lst@MakeCaption. This modification seems to trigger the problem here. I'm not sure whether the bug lies in modifications done by caption , in listings package which defines interface to fancyvrb , or in the fancyvrb package, but as a workaround for this bug you could restore original \lst@MakeCaption version, inside mmaCell:

\documentclass[12pt]{article}
\usepackage{caption}
\usepackage{mmacells}


\makeatletter
% Restore original listings caption inside mmacells.
\mmaSet{morefv={formatcom*={\let\lst@MakeCaption\caption@ORI@lst@MakeCaption}}}
\makeatother


\begin{document}

\mmaSet{morefv={gobble=2}}

\begin{mmaCell}[moredefined={SumFirst,SumFirstSquares,SumFirstCubes},morepattern={n_,n},functionlocal=i]{Input}
  SumFirst[n_]:=Sum[i,\{i,1,n\}];
  SumFirstSquares[n_]:=Sum[\mmaSup{i}{2},\{i,1,n\}];
  SumFirstCubes[n_]:=Sum[\mmaSup{i}{3},\{i,1,n\}]
\end{mmaCell}

\end{document}

pdf with workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants