jkuczm / mmacells Goto Github PK
View Code? Open in Web Editor NEWMathematica cells in TeX
Mathematica cells in TeX
Hi,
I have been using mmacells for a while on Overleaf. However, I have to change the TexLive version to 2020 in order for it to work.
When using TexLive 2021, I get the following error:
! Undefined control sequence.
<argument> ...otalleftmargin \hbox_unpack_clear:N
\@labels
l.143 \begin{mmaCell}{Code}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
When using the 2022 version, there are no errors but the In[x] and Out[x] do not appear: Here's what this code prints
\begin{mmaCell}[]{Code}
Apart[1/(s^2-1)]
\end{mmaCell}
\begin{mmaCell}{Output}
1/(2 (-1 + s)) - 1/(2 (1 + s))
\end{mmaCell}
Greetings, jkuczm. First of all, I want to thank you for your CellToTeX-SyntaxAnnotations-mmaCells bundle.
I have the following issue: if I have several "keywords" connected by "@" symbol without spaces, then the whole structure is coloured with blue.
If I understand the situation correctly, listings interprets the whole structure as a whole keyword because "@" is a letter by listings' defaults, but maybe I am wrong. I tried to change the role of "@" symbol to "other" and it seemed to work correctly...
Hi, thanks for the fantastic package. I'd really like to give it a try, but when i installed the sty. file (putting it in the same folder as my tex. file), and compile my tex. file, it gave such errors as shown in the figure below. I'm very new to latex/tex. The tex. file is copied from one of your post here.Could you help me with this? Thank you! :) (sorry for reporting this as a new issue)
Hi jkuczm,
Is it possible to create a more detailed documentation for this package?
I have been using it to write a lecture note introducing MMA to students a few years ago. This has been a wonderful package to used.
However recently some unknown package update (I guess) made the generated PDF looks bad.
So I downloaded the newest mmacells package and now it looks much better, but still there are a few parameters I want to personalize.
Is it possible to write a full documentation, explaining the meaning of various parameters and how to control them?
E.g., margin size, label width, color etc.
Greetings again, jkuczm.
The issue is the following. Let us consider Xe(La)TeX + polyglossia bundle for non-english (russian in my case) document preparation.
There is a well-known issue with polyglossia package that an error
! Package polyglossia Error: The current roman font does not contain the Cyrill
ic script!
(polyglossia) Please define \cyrillicfont with \newfontfamily.
See the polyglossia package documentation for explanation.
arises while using some verbatim environments like Verbatim one provided by fancyvrb package, which is used by mmacells. One can find a solution (see e.g. http://tex.stackexchange.com/questions/91507/liberation-mono-the-current-roman-font-does-not-contain-the-cyrillic-script on tex.stackexchange.com) for this problem to add a string
\newfontfamily\cyrillicfonttt{lmmonolt10-bold.otf}
in a document.
The point is that, while this string helps in case of Verbatim environment and, furthermore, there is no any problem with lstlisting environment, even without this "help-string", mmaCell environment still leads to above mentioned error. I.e. this "help-string" doesn't help in the case of mmaCell environment.
For clarity:
\documentclass[a4paper,10pt]{article}
\usepackage[quiet]{fontspec}
\usepackage{polyglossia}
\usepackage{unicode-math}
\usepackage{mmacells}
\setmainfont[Ligatures=NoCommon]{Times New Roman}
\setmathfont{xits-math.otf}
\setmainlanguage{russian}
\setotherlanguage{english}
%\newfontfamily\cyrillicfonttt{lmmonolt10-bold.otf}
\begin{document}
Русский текст.
\begin{Verbatim}
f[x]
\end{Verbatim}
\end{document}
leads to error, while
\documentclass[a4paper,10pt]{article}
\usepackage[quiet]{fontspec}
\usepackage{polyglossia}
\usepackage{unicode-math}
\usepackage{mmacells}
\setmainfont[Ligatures=NoCommon]{Times New Roman}
\setmathfont{xits-math.otf}
\setmainlanguage{russian}
\setotherlanguage{english}
\newfontfamily\cyrillicfonttt{lmmonolt10-bold.otf}
\begin{document}
Русский текст.
\begin{Verbatim}
f[x]
\end{Verbatim}
\end{document}
does not. I don't even need to declare english environment explicitly.
And this one
\documentclass[a4paper,10pt]{article}
\usepackage[quiet]{fontspec}
\usepackage{polyglossia}
\usepackage{unicode-math}
\usepackage{mmacells}
\setmainfont[Ligatures=NoCommon]{Times New Roman}
\setmathfont{xits-math.otf}
\setmainlanguage{russian}
\setotherlanguage{english}
\newfontfamily\cyrillicfonttt{lmmonolt10-bold.otf}
\begin{document}
Русский текст.
\begin{mmaCell}{Input}
f[x]
\end{mmaCell}
\end{document}
leads to the error anyway.
So, maybe something in mmacells package just doesn't let this trick to work?
P.S.
LaTeX + fontenc + inputenc + babel bundle seems to work fine, i.e.
\documentclass[a4paper,10pt]{article}
\usepackage{mmacells}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage[english,russian]{babel}
\begin{document}
Русский текст.
\begin{mmaCell}{Input}
f[x]
\end{mmaCell}
\end{document}
works fine. But sometimes it's necessary to use XeTeX...
P.P.S.
Oh, by the way, I omitted \begin{english} and \end{english} because it does not help without help-string present anyway (this is the bug of polyglossia) and after explicit redefining there is no need of them. But
\documentclass[a4paper,10pt]{article}
\usepackage[quiet]{fontspec}
\usepackage{polyglossia}
\usepackage{unicode-math}
\usepackage{mmacells}
\setmainfont[Ligatures=NoCommon]{Times New Roman}
\setmathfont{xits-math.otf}
\setmainlanguage{russian}
\setotherlanguage{english}
\newfontfamily\cyrillicfonttt{lmmonolt10-bold.otf}
\begin{document}
Русский текст.
\begin{english}
\begin{mmaCell}{Input}
f[x]
\end{mmaCell}
\end{english}
\end{document}
still doesn't work, while
\documentclass[a4paper,10pt]{article}
\usepackage[quiet]{fontspec}
\usepackage{polyglossia}
\usepackage{unicode-math}
\usepackage{mmacells}
\setmainfont[Ligatures=NoCommon]{Times New Roman}
\setmathfont{xits-math.otf}
\setmainlanguage{russian}
\setotherlanguage{english}
\newfontfamily\cyrillicfonttt{lmmonolt10-bold.otf}
\begin{document}
Русский текст.
\begin{english}
\begin{Verbatim}
f[x]
\end{Verbatim}
\end{english}
\end{document}
does.
Spotted in #39.
If you encounter this bug, e.g. when using explicit context mark in symbol names, as a workaround use:
\mmaSet{morelst={alsoletter={`}}}
Hi,
How can I move the \includegraphics{}
so that the "Out[...] =" label is centred vertically relative to graphics height? I can move it left/right using \mmaCellGraphics[ig={trim= -1cm 0cm 0cm 0cm}]{Output}{fig.pdf}
.
Best wishes, Jose Sa
Hi, I tried to import package without installation:
Import["https://raw.githubusercontent.com/jkuczm/MathematicaCellsToTeX/master/NoInstall.m"]
Mathematica returns a list of errors. See the attached notebook. Please tell me what can I do
Thank you
Best Regards
CellsToTeX.nb.zip
This is the minimal tex file.
\documentclass{article}
\usepackage{unicode-math}
\usepackage{mmacells}
\begin{document}
\begin{mmaCell}{Input}
\mmaSub{x}{1}==\mmaFrac{-b\(\pm\)\mmaSqrt{\mmaSup{b}{2}-4 a c}}{2 a}
\end{mmaCell}
\end{document}
I get the error "Improper alphabetic constant". And I am using texlive 2015.
Hey,
today I tried to use mmacells
on a fresh windows with new MiKTeX. Unfortunately, I get an error message when compiling the following minimal example:
\documentclass{article}
\usepackage{mmacells}
\begin{document}\begin{mmaCell}{Input}
\mmaSub{x}{1} == \mmaFrac{-\mmaUnd{(\pmb{\beta})} (\pmb{\pm}) \mmaSqrt{\mmaSup{\mmaUnd{(\pmb{\beta})}}{2} - 4 \mmaUnd{(\pmb{\alpha})} \mmaUnd{(\pmb{\gamma})}}}{2 \mmaUnd{(\pmb{\alpha})}}
\end{mmaCell}\end{document}
The error message is:
! Undefined control sequence.
...otalleftmargin \hbox_unpack_clear:N
@labels
l.5 \begin{mmaCell}{Input}
I attached the log file for more information.
Best, johinoli
It seems to me that the mmaCellGraphics can go oversize. I think probably it pass a width=\columnwidth
as default \includegraphics
parameter? I'm wondering whether there could be a way to specify a width or a scale, and how to set the default value.
Hello,
When I use pdflatex on the following code, compilation never completes.
\begin{mmaCell}{Output}
\mmaFrac{1}{4} \
(-\mmaFrac{\mmaSup{e}{-\mmaFrac{\mmaSup{(-I0+ID)}{2}}{2 \
\mmaSup{s0}{2}}} \
\mmaSqrt{\mmaFrac{2}{\(\pi\)}}}{s0}+\mmaFrac{\mmaSup{e}{-\mmaFrac{\m\
maSup{(I1-ID)}{2}}{2 \mmaSup{s1}{2}}} \mmaSqrt{\mmaFrac{2}{\(\pi\)}}}{s1})
\end{mmaCell}
Any idea why it hangs?
Hi,
If I try to call \mmaInlineCell before a mmaCell environment I get the following error:
Missing \endcsname inserted.\unhbox ...l: \mmaInlineCell[]{Code}{Module[{a=5}, a]}
Minimal TeX code:
\documentclass[12pt]{article}
\usepackage{mmacells}
\begin{document}
%\begin{mmaCell}[functionlocal=y]{Code}
% Integrate[y,{y,0,1}]
%\end{mmaCell}
Inline cell: \mmaInlineCell[]{Code}{Module[{a=5}, a]}.
\end{document}
I'm from China. So I need package ctex
to input Chines characters.
But the indent is strange when I use it with ctex
\documentclass{article}
\usepackage{ctex}
\usepackage{mmacells}
\begin{document}
\begin{mmaCell}{Output}
\{1,2
3,4\}
\end{mmaCell}
\begin{Verbatim}[commandchars=\\\{\}]
\{1,2
3,4\}
\end{Verbatim}
\end{document}
Hi,
Is there a way to get automatic line break?
(the same as the "breaklines=true" option of the lstlisting package)
Thanks!
Best,
Rafael
In #20 @Nithilher wrote:
I have one small request. I would like to set the Input Code of mathematica in
borderless boxes of full width (\ŧextwidth) with a light gray as background
color. However, when putting your code within \colorbox{bg}{...}
, I get an error:
\definecolor{bg}{rgb}{0.95,0.95,0.95}
\colorbox{bg}{%
\begin{mmaCell}[morepattern={z, z_}]{Input}
\mmaDef{ρ}[z_] := \mmaSub{ρ}{0} z Exp[-\mmaUnd{λ} Abs[z]]
\end{mmaCell}
}
yields
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
...
Is there a simple way to achive this?
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}
Is there a way to add a caption using this package. I am trying this code
\begin{mmaCell}[
label=,
linkbuiltin=List,
pattern={fun, arg, c, len},
moredefined={RandomReal},
caption={My Caption}
]{Input}
fun = Function[{len},
NestList[
Function[{c},
Module[{arg = RandomReal[{0., 2. Pi}]},
{Sin[arg], Cos[arg]}
] + c
],
{0., 0.},
len
]];
\end{mmaCell}
Hi,
Is it possible to obtain the Mathematica TraditionalForm in an output cell generated in a Mathematica notebook with MathematicaCellsToTeX and Mmacells?
Thanks
Is there any options to control the position of label, like this:
XXXX In[ ]: XXXX Code -> XX ln[]: XXXX Code
A small question:
The counter will not reset when I start a new Chapter in the {book}.
Now I use [index=1] to reset, but I think it can be auto reseted.
Is there a way to reference the mathematica cell/code block like you would when using the regular listings package? Would an extension of this allow the creation of a list of code blocks like the \lstlistoflistings function does?
hi, thx for your package- it looks very nice imo.
however, in my code i have matrices as input, but i do not know how to create a matrix inside a mmaCell. If possible, could u explain? thx in advance
greets
Edit: Also, if i may ask, it would be awesome to have a box around the code as it is possible using listings. Is there also a command for that in mmaCell? thx!
Currently some Mathematica commands are known, such as Sin, Cos, Exp etc. These will therefore show as black, as in Mathematica. However, it only seems to be a subset of the possible commands, as slightly more obscure functions such as PolarPlot are not included.
I don't see where the already known commands are defined, in order to be able to add more.
I can add them to each individual mmacells call as defined=..., but a way to specify them upfront would be good.
when compiling, the following error emerges:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "keys/property-unknown"
!
! The key property '.initial:n' is unknown.
!
! See the LaTeX3 documentation for further information.
!
! For immediate help type H .
!...............................................
l.371 }
|'''''''''''''''''''''''''''''''''''''''''''''''
| This is a coding error.
|
| LaTeX has been asked to set the property '.initial:n' for key
| 'mmacells/verbatimenv': this property is not defined.
|...............................................
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.