New functions in TexAct

130 views
Skip to first unread message

TB

unread,
Oct 29, 2013, 1:43:54 PM10/29/13
to xa...@googlegroups.com
Hi xAct users!

I have implemented some new functions in TexAct.

* The TexBreak function can now measure how wide an expression will be in the final tex output. This is done by sending the code to the external latex program.
For instance one can write
TexBreak[%, latextextwidth, TexBreakBy -> "TexPoint"]
or
TexBreak[%, 300, TexBreakBy -> "TexPoint"]

The second argument tells how many printer points wide the line should maximally be. For convenience, one can also use the latextextwidth symbol which represents the textwidth parameter in latex. In fact any expression involving numbers and the latextextwidth symbol should work.

* The functions TexPrintAlignedExpressions and TexPrintAlignedEquations can take a list of expressions or equations respectively, and produce full latex code using the align environment. Appropriate line breaks are inserted so that the length of the lines do not exceed the value $TexPrintPageWidth, which defaults to latextextwidth.

* The function AddEquationMarks can be used to add \begin{equation} and \end{equation} etc. to a string of latex code. It can also make an educated guess of which environment to use.

* FormatTexBasis can be used to specify special tex code for Basis objects in the same way as FormatBasis specifies how it should be displayed on the screen.

* The function TexView can take a list of equations or expressions, a single equation or expression or a string of latex code. From this it produces a complete .tex file, typesets it and opens the compiled file. The latex compiler can be chosen by $LatexExecutable (default is pdflatex), and the extension of the file to open is given by $TexViewExt. The files produced by TexView will be stored in $TexDirectory, while the temporary files used by TexBreak will be stored in the directory $TexTmpDirectory.
The latex class can be specified by $TexInitLatexClassCode, while packages and extra initialization code can be given in $TexInitLatexPackages and $TexInitLatexExtraCode respectively. Observe that $TexInitLatexPackages and $TexInitLatexExtraCode are lists of strings so it should be easier to check if some code is already there before you add it.
Observe that these settings affect both TexView and TexBreak.

Hopefully, TexAct should now be able to produce all the latex code for your equations. Unfortunately you still have to write the text of your papers manually. :)


Observe that these features are not fully documented yet, and that some names etc. might change in the near future. Hopefully you will find enough information in the this email and the usage messages to use the new features. The source code might also help, but it is more difficult to read.
As this is not a full release yet, it can not be downloaded from the xAct web page, but it can be downloaded from

https://github.com/xAct-contrib/TexAct

For most users it is enough to replace the old TexAct.m file. (Under windows this file may appear in two places.)

Please tell me what you think.

Regards
Thomas

Leo Stein

unread,
Oct 29, 2013, 2:06:00 PM10/29/13
to TB, xAct Tensor Computer Algebra
Just to add to Thomas's message: You can pull from github without an account via
git clone git://github.com/xAct-contrib/TexAct.git
in the directory where you want TexAct/ to live. Alternatively, if you
want to download a .zip or .tar.gz you can grab them here:
https://github.com/xAct-contrib/TexAct/releases/tag/0.3.3

Leo
> --
> You received this message because you are subscribed to the Google Groups
> "xAct Tensor Computer Algebra" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to xact+uns...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Jose

unread,
Nov 15, 2013, 2:23:09 AM11/15/13
to xa...@googlegroups.com, TB
Thomas, this is so very nice! It is great that you know simultaneously so much Mathematica and LaTeX.

The TexView command is amazing. Let me mention here two things:

The first one is that, in my unix environment, your code didn't work directly for me. But it was very simple to fix: I went to the command line and wrote

    jose$ which pdflatex
    /opt/local/bin/pdflatex

so I copied in Mathematica, with TexAct already loaded:

    $LatexExecutable = "/opt/local/bin/pdflatex"

Then everything worked fine. I know I could configure some paths somewhere, but this is simpler.

The second thing is that in order to use TexView one needs to go through three steps (correct me if I'm wrong):

...
Out[]= <big equation>

In[]:= TexPrint[%]
Out[]= <a latex string>

In[]:= AddEquationMarks[%, "equation*"]
Out[]= <another latex string>

In[]:= TexView[%]

Typesetting OK.
Opening file: TexActView.pdf

and then I got a neatly formatted pdf of the original equation.

I would suggest that if TexView receives directly something which is not a string then you automatically call TexPrint and AddEquationMarks on that input. Then TexView[tensor_expression] would show a formatted pdf, which would be so very useful.

Thanks again Thomas.

Cheers,

Jose.

Thomas Bäckdahl

unread,
Nov 15, 2013, 9:42:32 AM11/15/13
to xa...@googlegroups.com
Hi!


On 2013-11-15 07:23, Jose wrote:
Thomas, this is so very nice! It is great that you know simultaneously so much Mathematica and LaTeX.

The TexView command is amazing. Let me mention here two things:

The first one is that, in my unix environment, your code didn't work directly for me. But it was very simple to fix: I went to the command line and wrote

    jose$ which pdflatex
    /opt/local/bin/pdflatex

so I copied in Mathematica, with TexAct already loaded:

    $LatexExecutable = "/opt/local/bin/pdflatex"

Then everything worked fine. I know I could configure some paths somewhere, but this is simpler.

Yes, unfortunately this is what you have to do if the paths are not set. I hope this is not too troublesome. Perhaps some documentation about this could be added.


The second thing is that in order to use TexView one needs to go through three steps (correct me if I'm wrong):

...
Out[]= <big equation>

In[]:= TexPrint[%]
Out[]= <a latex string>

In[]:= AddEquationMarks[%, "equation*"]
Out[]= <another latex string>

In[]:= TexView[%]

Typesetting OK.
Opening file: TexActView.pdf

and then I got a neatly formatted pdf of the original equation.

I would suggest that if TexView receives directly something which is not a string then you automatically call TexPrint and AddEquationMarks on that input. Then TexView[tensor_expression] would show a formatted pdf, which would be so very useful.

With TexAct version 0.3.3 (2013-10-24) the TexView function can take a tex string as in your example, but it also works directly with an expression, a list of expressions, an equation or a list of equations.

Hence, your example can be simplified to

Out[]= <big equation>

In[]:= TexView[%]

Typesetting OK.
Opening file: TexActView.pdf

In this case the equation marks are chosen automatically to match the type of expression you have. Please let me know if these choices are bad. I could add some options for TexView to control these things if that would be helpful.

Regards
Thomas
Reply all
Reply to author
Forward
0 new messages