This way, you can safely copy only the equation from $Equation$ and paste it into the equation window on the pages. But in this case, it is difficult for me to complete step 4). The cursor does not stop and continues to move to the end of the document. Is there any action that can make 4) possible?
But it's not, is it, for what I suggested (namely paste the whole thing without dollar signs into the equation editor in Pages) will not render properly.
What you actually need for the text to be pasted into Pages unchanged, but the maths expressions to be entered via the equation editor.
I'm just trying to clarify what it is you're trying to achieve. To take your example
$math1$text1$math2$text2
Is this what you want to happen:
Enter math1 via the equation editor
Paste the text1 into Pages
Enter math2 via the equation editor
Paste the text2 into Pages
To be absolutely certain, it would be better if you posted actual examples of
(a) the text that you start with, and
(b) what it looks like in Pages after it's been properly entered
Tangent to your question but clarifying the method in LaTeX ... punctuation marks (comma and question mark) should be rendered outside of the equation limits not inside them. So $x = 4$, not $x= 4,$.
I’ve now looked at your example and I have figured out a way to achieve what you want.
Well - that’s the good news!
The bad news is that it is so complicated there must be different, simpler ways of solving the same problem. It’s just that I currently don’t have enough spare time and brain power to go further.
So, I’m hoping some kind (and canny) soul will step in and have a shot at helping you and we can both learn a bit more.
I might hazard a guess that the KM conversion will need a loop that pulls apart a sequences of (regular text + LaTeX) + (regular text + LaTeX) + ... The command will paste the regular text into Pages. At each LaTeX, the command will have to open the equation editor in Pages, enter the text, and exit the editor (invoking it). Repeat this until the end of the text buffer.
When this is to be done on more than one set of inputs, I have to wonder why not just use a LaTeX compiler directly?
That's a bird's-eye view of what's needed: I've already worked out how to identify where each LaTeX element is by locating the dollar signs (and therefore where each text element is) and written a macro to do that but the iterating loop that then extracts these elements turns out to be very fiddly. But that's my take on it and I was wondering if there might be another, simpler approach that someone can suggest. It seems to me that while KM can process text sequentially, it's not necessarily something that KM makes easy to do!
I'm not really familiar with LaTeX so your suggestion to use a LaTeX compiler sounds to me like that could be the more straightforward approach.
This is a discussion worth a thread on its own. Suffice to say that, the (highly) recommended on-line compilers are OverLeaf or ShareLaTeX, and the macOS local installation is (so easy, a caveman can do it) found at MacTex.
I think perhaps that the OP is trying to get out of investing time to learn LaTeX and instead wants a parsing tool to be able to copy+paste someone else's LaTeX work to his favorite WYSIWG text editor (Pages).
But, that is also a subject for its own thread (not here).
I have also considered using LaTex compilers like "Lyx" or "Overleaf" before, but I have come to the conclusion that these compilers are more suitable for writing "Professional" math or scientific papers.
The document I wanted to create had to be in a more free form with pictures, text, and equations, so I considered "Pages".
Perhaps even with a direct LaTex compiler, various images, texts, and formulas can be freely implemented like a textbook that elementary school children see, so I will study more.
To use the macro, you must copy the raw source text into the clipboard and then trigger the macro; I've set it to trigger on [hyper]-; but of course you can set it to whatever you like.
The macro will then activate Pages, to make sure it's at the front and then do it's stuff.
EDIT: I was just playing around with this and discovered an omission such that if there was plain text after the last LaTeX element it would not be output to Pages, so I've updated the macro to fix this.
This just goes to show that you'll need to test this on as many examples as possible!
FWIW, in such cases, I use Curio with LaTeXiT (although Curio supports LaTeX equations as well). Curio has a much wider range of options for types of content that can be added to the page and a broader definition of "free form layout".
Thank you very much for telling me a very fantastic editor.
I visited the site you mentioned, downloaded the program, and tried it for hours. And, unfortunately, I have identified a few trivial but important facts that the program does not fully support LaTex.
In particular, there was something I wasn't happy with about inline LaTex. It is more of a problem with my LaTex code itself than a problem with the program.
Anyway, I came back to Pages. It was a short but intense tour.
Thank you.
On my machine, this macro doesn't work (I can't hit the run button), maybe there's a problem with my machine settings. I will study the macro you gave me and update it.
You will possibly need to enable the macro as usually they are installed disabled to prevent accidental (and malicious) usage. Check the box highlighted here:
The problem is that you are trying to compile LaTeX equations and normal text all at the same time. The best option is to use a LaTeX application itself.
You are finding out that, when you work with components that have LaTeX, you have four options:
Manually enter the text and LaTeX into Pages (or another program), switching each time between normal text and LaTeX.
Create / find a (complex) macro that will do the above for you.
Learn LaTeX with a real LaTeX editor application, also learning how to put figures into the document.
Change your approach to separate the LaTeX math from the normal text and figures, for example so that you are not trying to run an in-line mode of compilation over an entire paragraph of input.
I will close with one example of a lecture slide that I generated in Curio to combine text, equations, mind maps, and pictures.
The equations are embedded using LaTeXiT, not with the equation editor in Curio (while it is good in its own right, it is only a recent addition to Curio, and I have a longer history of developing equations into Curio with LaTeXiT).
For the opposing view of paginated documents with text, images, and equations, you need only visit any one of the many journal articles in physics, chemistry, or other disciplines. Many of them have their source files generated entirely in LaTeX formats.
My recommendations in summary: If you are generating a paginated document, learn to use LaTeX directly. It is really not that hard to embed text, math, and images to that point that wrapping around figures is also possible. If you are generating a free-flowing document (what I might call a white board), learn to separate the components for math (LaTeX), normal text, images, and other content to be able to work properly with each tool.