Message Boards Message Boards

7
|
23247 Views
|
6 Replies
|
23 Total Likes
View groups...
Share
Share this post:

Styled notebook with LaTeX appearance

There are a number of so-called Styled notebooks available for writing journal papers, preprints, but they all have their own styles and limitations. Since I am usually writing my papers with LaTeX, I think it would be useful to have a Styled notebook which has the looks as a LateX output. Of course you might ask why do not use LaTeX directly instead, but the answer is that at the same time I want to keep all other functionality of Mathematica.

More generally, such a notebook would be useful for two reasons. One, if the emphasis is on the calculations, then of course a default notebook will do, but it will only be readable for the author. To make it useful also for others, then, with the notebook I am seeking, one can comment the formulae in an aesthetically pleasing form in between the input formulae/calculations. This is very useful if two or more people collaborate on a subject (I try to establish this with my PhD students). Two, if one collects all the calculations at the end of the file like an Appendix and makes a rich description in the first part of the notebook of what the calculations are about, then one will have in the end a nearly ready draft of a paper which can very easily be converted into LaTeX for journal submission. So until the last step, one would work within one file for calculations, plotting, and paper writing, and producing a paper/preprint etc. from the material would be significantly reduced.

The main message of this note is that I got to somewhere in such an effort which I would be glad to share with the Community, as well as to get some feedback and help with some open questions, described below. There is at least one puzzle for the real hackers, if anyone is interested in such. I am also aware that in some cases I am knocking on open doors, and what I am looking for is already solved, probably more elegantly. I appreciate any such info. 
Here is a snapshot of part of a sample notebook that I created, which shows the text generated and illustrates the problems.



One nice feature which the above illustrates, and which is far from trivial, that the expressions in the display equations are italic, but the equation numbers are plain. This was achieved by editing the corresponding style definition by kind help of Martin Hadley of Wolfram Research. This is the definition of the style of EquationNumbered: 
 Cell[StyleData["EquationNumbered"],
  CellMargins->{{60, Inherited}, {Inherited, Inherited}},
  CellFrameLabels->{{None,
     Cell[
      TextData[{
        StyleBox["(", FontSlant -> "Plain"],
        CounterBox["EquationNumbered"],
        StyleBox[")", FontSlant -> "Plain"]}], "EquationNumberedEquationNumber", FontSlant ->
      Plain]}, {None, None}},
DefaultFormatType->TraditionalForm,
TextAlignment->Center,
CounterIncrements->"EquationNumbered",
MenuSortingValue->1450,
MenuCommandKey->"6",
FontFamily->"Euclid",
FontSlant->"Italic"]

The problems that remain, also illustrated in the sample text above, are that 

- numbers should be plain and not slanted (i.e. not italic)
- the Greek symbols are already slanted in Euclid by default, and putting the slant to italic of the Euclid makes the slanting of the Greek symbols twice that of the latin ones.

Martin had an interesting suggestion, to use the command 
LanguageCategory->"Formula"

in the style definition. Here comes the real thriller emoticon . This definition indeed keeps numbers straight, and other symbols slanted. However, the slanted property will be valid only to single characters. So one would have correctly forms like (1 + a), with "a" in italic, but it would turn to (1 + ab) with "ab" in plain, if instead of the single "a" the symbol is "ab". This is a mystery which would be interesting to understand.
I uploaded the full sample notebook from which a graphical excerpt is shown above, to

https://www.dropbox.com/s/zvx7a3fc4lu00ba/sample_latex.nb

It contains also the description of the goals and problems which are described in this discussion  

It would be great to get comments on the usefulness of the idea, on the solution of the remaining problems, and possibly about already existing solutions which I am not aware of.

Best regards
Imre 
POSTED BY: Imre Pazsit
6 Replies

Since this question became interesting in two other conversations recently, I am uploading here the slightly modified version of the style file, in which the above suggestions/solutions are implemented.

Attachments:
POSTED BY: Imre Pazsit
Dear John and Andre,

Thank you very much for your comments which solved all the problems and even more than what I asked - I really appreciate! I am sorry for a very slow confirmation, it has its reasons, but the main thing is that I hope a slow response will not put you off to give feedback even in the continuation emoticon .

To use the invisible Times sign in each case would be too laborious, but the suggestion of using
SingleLetterItalics->True, MultiLetterItalics->True
in my file works like magic; the slant of the greek and latin letters becomes equal ("single italic"), and the arabic numbers remain plain. So this is great. The only slight problem is that when I want to have a latin letter and a number next to each other, because then the number remains italic, such as a1. If the sequence is the opposite, first a number and then a letter, then the slants get correct, but the two symbols get apart from each other, as if there was a space in between, such as  1 a instead of 1a. However, both  of these problems can be cured by using the invisible Times sign in between.  

So this solves all the issues I had with the file. And I also appreciate the warning about the preserving of the semantics. Yes, I myself often need to copy and paste and evaluate the expressions, since as I wrote in the original note above, I am also doing the calculations at the end of the file in an appendix, i.e. doing the calculations and writing the paper simultaneously. The multiple letter constructs are sometimes products, sometimes they stand for a single variable. But I know which is which, so I can keep track between them and have the correct form for the evaluation.

Thank you again and I look forward to get more support when and if a question will arise again.
POSTED BY: Imre Pazsit
I agree with Andre that, if the semantic meaning of the multi-letter strings is to multiply single-letter variables together, you should use InvisibleTimes.  Even if these equations are not meant to be evaluated, somebody may very well copy and paste them, in which case preserving semantic meaning may be desirable.

And since the FE may alter its typesetting based upon its semantic understanding of that typesetting, preserving the underlying semantics is generally a good principle to follow.
POSTED BY: John Fultz
Oops, I see John responded with the MultiLetterItalics->True suggestion, which is also fine if that works across the board for you.

AK
POSTED BY: Andre Kuzniarek
For the case of maintaing italics when variables are positioned together (implying multiplication), we recommend the use of the InvisibleTimes special character. One would type:
1+a\\[InvisibleTimes]b
I'm escaping the backslash here, just to keep the long name exposed, otherwise it collapses when publishing the post.

I'll take a look at your uploaded notebook and see if I have any other suggestions about achieving your goals, thanks.

AK
POSTED BY: Andre Kuzniarek
To fix your italics problems, replace every instance in your stylesheet of
FontSlant->"Italic"
with
SingleLetterItalics->True, MultiLetterItalics->True

This should resolve every complaint about italics that you made in your notebook.
POSTED BY: John Fultz
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract