jkuczm / mmacells

Mathematica cells in TeX
61 stars 18 forks source link

matrix input #37

Closed thimok92 closed 6 years ago

thimok92 commented 6 years ago

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!

jkissl commented 6 years ago

Have a look through the LaTex documentation on creating matrices, in there you ought to be able to find the right syntax to create a matrix in the cell. I had the same issue with my thesis, but I am away from the .tex file so I'll have to comment on how to exactly do it later on.

jkuczm commented 6 years ago

@thimok92 Could you give an example of a matrix that you'd like to have in mmaCell? Depending on whether entries in this matrix are visually closer to "code" or to "mathematical expressions" different solutions might be best.

Are you writing mmaCells TeX code manually, or do you use CellsToTeX Mathematica package?

As to box around the code see issue #21.

thimok92 commented 6 years ago

@jkuczm Hey! First, thx for solving the box-issue, works perfect. Second, I am writing the mmaCells manually in TeX. I guess the matrices I use are less code than mathematical, e.g.

(I included the file as picture, hope it worked)

thimok92 commented 6 years ago

Sorry, it's not working properly for me atm- it seems not to upload the pic =/ However, they are easy to describe in words^^: I got 11x11 matrices with entries having one of the following 4 types:

jkuczm commented 6 years ago

@thimok92 There are two approaches you could use.

First is to rely on verbatim environment used by default in mmaCell. You will not have round brackets around matrix that are visible in Mathematica when using MatrixForm and you'll have to manually insert spaces necessary for aligning columns, but matrix elements will be automatically styled.

\begin{mmaCell}{Code}
{{0, 1}, {d12, adx1[[1, 3]]}} // MatrixForm // HoldForm
\end{mmaCell}

\begin{mmaCell}{Output}
 0       1
d12 adx1[[1, 3]]
\end{mmaCell}

verbatim

Second approach is to switch off verbatim environment by using verbatimenv= option and use ordinary LaTeX matrix commands. This approach requires manual styling of each matrix element.

\begin{mmaCell}{Code}
{{0, 1}, {d12, adx1[[1, 3]]}} // MatrixForm // HoldForm
\end{mmaCell}

\begin{mmaCell}[verbatimenv=]{Output}\(\begin{pmatrix}
\texttt{0}   & \texttt{1} \\
\texttt{d12} & \texttt{adx1[[1, 3]]}
\end{pmatrix}\)\end{mmaCell}

nonverbatim

thimok92 commented 6 years ago

ahh i see, thank you very very much dear sir!!!! best regards

thimok92 commented 6 years ago

@jkuczm sorry to bother you once again: 1) it seems like there is a vertical space of 1-2cm before the inputs, e.g. __ In[1]:= XXXXXXX i.e. it is not aligned to the most left.

2) another issue i have is that your environment "boxedMmaCell" (which u defined in an answer to a question) does not work together with the option [veratimenv=] which i use to display matrices.

Are there easy options to solve the above two things? thx in advance

jkuczm commented 6 years ago

@thimok92 As to left margin see issue #35.

As to second issue it's possible that \VerbatimEnvironment command is breaking something when used in non-verbatim environment. You could define separate environment for boxed "matrix cells", without \VerbatimEnvironment, with hardcoded verbatimenv= option and pmatrix environment, something like:

\newenvironment{boxedMmaCellMatrix}[2][]
  {%
    \begin{tcolorbox}[colback=black!5!white,sharp corners,boxrule=0pt]%
    \begin{mmaCell}[#1,verbatimenv=]{#2}%
    \(\begin{pmatrix}
  }
  {%
    \end{pmatrix}\)%
    \end{mmaCell}%
    \end{tcolorbox}%
  }

\begin{boxedMmaCellMatrix}{Output}
\texttt{0}   & \texttt{1} \\
\texttt{d12} & \texttt{adx1[[1, 3]]}
\end{boxedMmaCellMatrix}