Coder Social home page Coder Social logo

mathematicacellstotex's People

Contributors

jkuczm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mathematicacellstotex's Issues

freeze on compiling with pdflatex for a particular code snippet

Hi,
the following tex file

\documentclass[12pt]{article}

\usepackage{mmacells}


\begin{document}

\begin{mmaCell}{Print}
  \mmaFrac{\mmaSub{\(\alpha\)}{s} (\mmaSub{C}{F}-\mmaFrac{\mmaSub{C}{A}}{2}) (\mmaFrac{1}{\mmaSub{\(\varepsilon\)}{IR}}+\mmaFrac{q2 (-\mmaFrac{1}{3
\mmaSub{\(\varepsilon\)}{IR}}+\mmaFrac{1}{3} log(\mmaFrac{m}{\(\mu\)})-\mmaFrac{1}{8})}{\mmaSup{m}{2}}-\mmaFrac{3}{2} log(\mmaFrac{m}{\(\mu\)})+\mmaFrac{1}{2
\mmaSub{\(\varepsilon\)}{UV}}+1)}{\(\pi\)}
\end{mmaCell}


\end{document}

fails to compile, by freezing pdflatex:
$pdflatex test.tex

This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2011/06/27>
Babel <3.9k> and hyphenation patterns for 8 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo)) (./mmacells.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3names.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3bootstrap.sty))
(/usr/share/texlive/texmf-dist/tex/latex/etex-pkg/etex.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3basics.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3expan.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3tl.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3seq.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3int.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3quark.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3prg.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3clist.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3token.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3prop.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3msg.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3file.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3skip.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3keys.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3fp.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3box.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3coffins.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3color.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3luatex.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3candidates.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty))
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/share/texlive/texmf-dist/tex/latex/bbm-macros/bbm.sty)
(/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/color.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix 
<2008/02/07> (tvz) (/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
)) (/usr/share/texlive/texmf-dist/tex/latex/listings/listings.sty
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstmisc.sty)
(/usr/share/texlive/texmf-dist/tex/latex/listings/listings.cfg))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/graphics.cfg)))
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty))
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty))

Package hyperref Message: Driver (autodetected): hpdftex.

(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hpdftex.def
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstmisc.sty)) (./test.aux)
(/usr/share/texlive/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./test.out) (./test.out)
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstlang1.sty)
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstlang1.sty)
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstlang1.sty)

after this line the CPU load goes crazy without any visible progress.

The code was obtained from the following cell

Cell[BoxData[
 RowBox[{"F1V", "=", 
  RowBox[{
   RowBox[{"(", 
    RowBox[{
     RowBox[{"SMP", "[", "\"\<alpha_s\>\"", "]"}], "/", "Pi"}], ")"}], 
   RowBox[{"(", 
    RowBox[{"CF", "-", 
     RowBox[{
      RowBox[{"1", "/", "2"}], " ", "CA"}]}], ")"}], 
   RowBox[{"(", 
    RowBox[{
     RowBox[{"1", "/", 
      RowBox[{"(", 
       RowBox[{"2", "EpsilonUV"}], ")"}]}], "+", 
     RowBox[{"1", "/", "EpsilonIR"}], "+", "1", "-", 
     RowBox[{
      RowBox[{"3", "/", "2"}], 
      RowBox[{"Log", "[", 
       RowBox[{"m", "/", "ScaleMu"}], "]"}]}], "+", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"q2", "/", 
       RowBox[{"m", "^", "2"}]}], 
      RowBox[{"(", 
       RowBox[{
        RowBox[{
         RowBox[{"-", "1"}], "/", 
         RowBox[{"(", 
          RowBox[{"3", "EpsilonIR"}], ")"}]}], "-", 
        RowBox[{"1", "/", "8"}], "+", 
        RowBox[{
         RowBox[{"1", "/", "3"}], 
         RowBox[{"Log", "[", 
          RowBox[{"m", "/", "ScaleMu"}], "]"}]}]}], ")"}]}]}], ")"}]}]}]], "Input",
 CellLabel->"In[10]:="]

I'm on Fedora 23, 64-bit with TeX Live 2014 from the standard repository and Mathematica 11. Am I doing something wrong here?

Cheers,
Vladyslav

Math mode in formatting commands

When expression or character requiring math mode is accompanied by something that doesn't require math mode inside argument, of formatting command, that is processed in math mode, then excessive math mode delimiters are used.

CellToTeX1^2 // MakeBoxes, "Style" -> "Input"]
(*
\begin{mmaCell}{Input}
  \mmaSup{\(\phi\)1}{2}
\end{mmaCell}
*)

Related to jkuczm/mmacells#20.

Problem generating TeX for Mathematica Cells that contain internal newlines/returns

[[ This is a great package—thanks for developing it; it is making a book project of mine much more tractable/better than it would have been ]]

I'm encountering a CellToTeX problem, that occurs when I try to generate TeX for cells that contain equations in which a function has an internal new-line. Mathematica ignores these, and I have included them to try to make the code more readable,, but CellToTeX seems to throw an exception

Let me show you an example:

psi1DPIB[n_, x_, L_] := Sqrt[2/L]*Sin[n*Pi*x/L];
g1 = Plot[
  {psi1DPIB[1, x, L], psi1DPIB[2, x, L]},
  {x, 0, L}, AxesLabel -> {"x", "\[Psi]"}
  ]

(note the newline between the entries within the Plot[] function) throws the following exception

CellsToTeXException::invalid: Following elements of type Boxes are invalid: RowBox[{g1,=,RowBox[{Plot,[,
,RowBox[{RowBox[{<<3>>}],,,
,RowBox[{<<3>>}],,,RowBox[{<<3>>}]}],
,]}]}]. Exception occurred in toInputFormProcessor[{<<1>>}].

and fails to render the text block. On the other hand, afterremoving the internal newlines from inside the Plot[] function,

psi1DPIB[n_, x_, L_] := Sqrt[2/L]*Sin[n*Pi*x/L];
g1 = Plot[{psi1DPIB[1, x, L], psi1DPIB[2, x, L]}, {x, 0, L}, AxesLabel -> {"x", "\[Psi]"} ]

everything works fine.

Is this an easy fix? I am running this on Mathematica 10.3.0.0

PacletInfo needs Context to load as installed

If a paclet is installed via PacletInstall it needs a "Kernel" extension with a "Context" spec to load properly it seems (just tried to load the installed paclet). Try changing the Extensions to:

Extensions -> 
        {
            {"Kernel", "Context"->{"CellsToTex`"}},
            {"Documentation", Language -> "English"}
        }

and then it should work fine.

TemplateBox with RowDefault tag is unsupported

It appears that a TemplateBox containing a "RowDefault" tag
cannot be processed properly. Cf. e.g. this typesetting code
from https://mathematica.stackexchange.com/questions/174627/writing-partial-differentiation-in-a-subscript/174630#174630

Derivative /: MakeBoxes[
    Derivative[n_Integer?NonNegative, m_Integer?NonNegative][f_], form_
] := SubscriptBox[
    MakeBoxes[f, form],
    TemplateBox[Join[ConstantArray["x", n], ConstantArray["y", m]],"RowDefault"]
]

When trying to apply CellToTeX to

Derivative[1, 0][f][x, y]

as in

CellToTeX[
 Cell[BoxData[
   FormBox[RowBox[{SubscriptBox["f", 
       TemplateBox[{"x"}, "RowDefault"]], "(", 
      RowBox[{"x", ",", "y"}], ")"}], TraditionalForm]], "Output"]]

the function fails.

According to

https://mathematica.stackexchange.com/questions/55363/incompatibility-of-row-and-texform/182382#182382

"RowDefault" was introduced in Mma 9. Indeed I can workaround the issue if I generate my cells
in Mma 8, where no such tags arise.

Unsupported box exception for every input

Hi,

I'm getting an unsupported box exception for every input no matter how simple it is. For example

CellToTeX[1, "Style" -> "Input"]

results in

CellsToTeXException::unsupported: Box: CellsToTeX`Private`AnnotateSyntax[1,Annotation->(CellsToTeX`Configuration`syntaxBox[#1,First[#2]]&),StringBoxToTypes->{SyntaxAnnotations`Private`str_/;SyntaxAnnotations`Private`$inFunction&&StringMatchQ[SyntaxAnnotations`Private`str,#*]:>{{PatternVariable,Function}},_?SyntaxAnnotations`Private`undefinedSymbolQ->{UndefinedSymbol},_String?SyntaxAnnotations`Private`symbolNameQ->{DefinedSymbol}},AnnotateComments->False] is not one of supported: {CellsToTeX`Configuration`syntaxBox[_,DefinedSymbol,___],CellsToTeX`Configuration`syntaxBox[_,UndefinedSymbol,___],CellsToTeX`Configuration`syntaxBox[_,LocalVariable,___],CellsToTeX`Configuration`syntaxBox[_,FunctionLocalVariable,___],CellsToTeX`Configuration`syntaxBox[_,PatternVariable,___],<<24>>,HoldPattern[UnderoverscriptBox[Repeated[_,{3}],OptionsPattern[]]],HoldPattern[FractionBox[Repeated[_,{2}],OptionsPattern[]]],HoldPattern[SqrtBox[Repeated[_,{1}],OptionsPattern[]]],HoldPattern[RadicalBox[Repeated[_,{2}],OptionsPattern[]]],_String}. Exception occurred in CellsToTeX`Configuration`boxesToTeXProcessor[{BoxRules->{CellsToTeX`Configuration`syntaxBox[CellsToTeX`Private`boxes$_,DefinedSymbol,___]:>\mmaDef{<>CellsToTeX`Configuration`makeString[CellsToTeX`Private`boxes$]<>},<<32>>,CellsToTeX`Private`str$_String:>StringReplace[CellsToTeX`Configuration`makeStringDefault[CellsToTeX`Private`str$],{Rule[<<2>>],Rule[<<2>>],Rule[<<2>>],Rule[<<2>>],Rule[<<2>>],Rule[<<2>>],Rule[<<2>>],RuleDelayed[<<2>>]}]},<<1>>,{Boxes->CellsToTeX`Private`AnnotateSyntax[1,Annotation->(CellsToTeX`Configuration`syntaxBox[<<2>>]&),StringBoxToTypes-><<1>>,AnnotateComments->False],<<3>>}}].

I read in another issue that, naturally, not all box types are supported, however as I'm not able to get even the simplest example working I'm guessing this is not the issue here. I have already tried several different inputs always resulting in an exception.

Bug in boxesToString Function

When using FormatType of "Input" or "Code" the output is littered with the useless string wBox. Your example of

testCell = Cell[BoxData[MakeBoxes[Subscript[x, 1] == (-b \[PlusMinus] Sqrt[b^2 - 4 a c])/(2 a)]], "Input"];
testCell // CellPrint
CellToTeX[testCell]

from the Mathematica StackExchange yields

\begin{mmaCell}{Input}
    \mmaSub{wBox[\{"x"}{wBox[\{"1"}wBox[\{"=="\mmaFrac{wBox[\{"-"wBox[\{"b"wBox[\{"\(\pm\)"\mmaSqrt{\mmaSup{wBox[\{"b"}{wBox[\{"2"}wBox[\{"-"wBox[\{"4" wBox[\{"a" wBox[\{"c"}}{wBox[\{"2" wBox[\{"a"}
\end{mmaCell}

The bug is in the boxesToString function at line 1210-1211.

makeStringDefault[str_String] :=
    StringTake[ToString[RowBox[{str}]], {3, -3}];

should read

makeStringDefault[str_String] :=
    StringTake[ToString[RowBox[{str}]], {10, -4}];

This change eliminates the wBox string from the output, as confirmed by the output once changed:

\begin{mmaCell}{Input}
    \mmaSub{x}{1}==\mmaFrac{-b\(\pm\)\mmaSqrt{\mmaSup{b}{2}-4 a c}}{2 a}
\end{mmaCell

Compatibility with Mathematica 13.0+

Neither loading nor using the package seems still to work in current versions of Mathematica.
Tested under Windows 10 with Mathematica 13.0, see the image below for the errors that appear.
Unfortunately, I was unable to pinpoint the problem any further by simply glancing over the code of the package.

image

Problems with integers inside boxes

The following code cannot be processed by CellToTeX

CellToTeX[
 Cell[BoxData[
   FormBox[FractionBox["1", 
     TemplateBox[{"\"(\"", 
       SuperscriptBox[
        FormBox[FormBox[StyleBox["k", Bold, StripOnInput -> False], 
          TraditionalForm], TraditionalForm], 2], "\"-\"", 
       RowBox[{"\[ImaginaryI]", " ", "\"\[Eta]\""}], "\")\""}, "Row", 
      DisplayFunction -> (RowBox[{#, "\[InvisibleSpace]", #2, 
           "\[InvisibleSpace]", #3, "\[InvisibleSpace]", #4, 
           "\[InvisibleSpace]", #5}] &), 
      InterpretationFunction -> (RowBox[{"Row", "[", 
           RowBox[{"{", 
             RowBox[{#, ",", #2, ",", #3, ",", #4, ",", #5}], "}"}], 
           "]"}] &)]], TraditionalForm]], "Output"]]

yet if I change 2 in the SuperscriptBox to "2" it works fine

CellToTeX[
 Cell[BoxData[
   FormBox[FractionBox["1", 
     TemplateBox[{"\"(\"", 
       SuperscriptBox[
        FormBox[FormBox[StyleBox["k", Bold, StripOnInput -> False], 
          TraditionalForm], TraditionalForm], "2"], "\"-\"", 
       RowBox[{"\[ImaginaryI]", " ", "\"\[Eta]\""}], "\")\""}, "Row", 
      DisplayFunction -> (RowBox[{#, "\[InvisibleSpace]", #2, 
           "\[InvisibleSpace]", #3, "\[InvisibleSpace]", #4, 
           "\[InvisibleSpace]", #5}] &), 
      InterpretationFunction -> (RowBox[{"Row", "[", 
           RowBox[{"{", 
             RowBox[{#, ",", #2, ",", #3, ",", #4, ",", #5}], "}"}], 
           "]"}] &)]], TraditionalForm]], "Output"]]

producing

\begin{mmaCell}{Output}
  \mmaFrac{1}{(\mmaSup{k}{2}-i \(\eta\))}
\end{mmaCell}

The bold styling of k is lost, but this is a lesser issue.

The input is a produced by some custom typesetting rules used in FeynCalc so this is probably
a not very common issue. Still, I'm wondering if there are any fundamental reasons why every non-box inside a box must be a string for CellToTeX to work properly?

Paclet server integration

I was wondering if you'd want to add your package to the Paclet Server / Package Repo) I've set up for the general Mathematica community. Per this I'm trying to increase awareness and get more paclets on the server so that more people can benefit from it.

I can handle any initial reformatting necessary to make everything work right, and I'll submit a pull request with any changes.

Error when a box has options

Bug reported by Matthew Galles.

When "formatting" boxes, like SuperscriptBox, have options, their conversion to TeX results in errors.

Minimal example is:

CellToTeX[SuperscriptBox["T", "1", MultilineFunction -> None], "Style" -> "Input"]
(* CellsToTeXException::unsupported: Box: MultilineFunction->None is not one of ...*)
(* Failure[...] *)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.