I'm a long-time latex user just learning to use jupyter notebooks. I've noticed that whenever I try to create latex-formatted equations in a markdown cell, the vector accents (created with "\vec{...}") are badly misplaced -- they show up way to the right of the character they are supposed to be accenting.
This seems like it must be a known/solved issue (probably an issue with MathJax, which I guess is what jupyter is using to process the latex?) but I couldn't find an answer anywhere. Indeed, searching around for an explanation/fix, I found a number of pages that explain how to create latex-formatted equations in mathjax/markdown that show (without identifying that it is a problem!) this misplacement, e.g.:
https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference (see the "\vec{x}" under accents near the bottom of the page)
http://jupyter-notebook.readthedocs.io/en/latest/examples/Notebook/Typesetting%20Equations.html (see Maxwell's equations)
http://data-blog.udacity.com/posts/2016/10/latex-primer/ (see again the "\vec{x}" under accents)
Why are the vector accents mis-placed like this, and how can this be fixed?
Any help appreciated!
Related
I'm trying to build a service that accepts some string with LaTeX formatting and then returns a string with the LaTeX bits as pngs, or whatever else.
So, the idea is:
client sends a request containing: the point is that $sum_{n=1}^5 f(x)$ is a good estimate
server sends back the string: the point is that FORMULAS_HERE is a good estimate
I really have no idea where to begin getting the LaTeX converted. Naively, I assume I would just parse out the LaTeX bits and then do something to get a png/jpeg/etc... and then insert that into the response.
Googling around really reveals minimal information.
Currently, my simple server is built on node, but that's not really important. I can change languages if there's some magic solution out there. I honestly wish I could magically transform LaTeX into unicode and have it be perfectly seamless.
Question: How do I handle LaTeX on the server side?
- The goal is to then spit it back to the client so the text can be inlined relatively naturally (i.e. I could text my buddy Hey, what if $\chi(n)$ was considered independently? and it would be received formatted on the other end without begin a weird big picture blob).
Any advice on just a direction or set of packages/technologies/etc.. would be useful here.
Prepare your latex document with math and convert it using the excellent open-source ImageMagick
pdflatex formula.tex
convert -density 300 formula.pdf -quality 90 formula.png
The convert command used above is one of the ImageMagick tools. See documentation and numerous online resources for many options. The software has versions for all major platforms.
The input latex file should be prepared so that there is no background, margins, etc. For discussion of how to do that, see this post, and the source for it. The example above ultimately comes from there.
This is one way to write the formula.tex file used above, from the linked source.
\ifdefined\formula
\else
\def\formula{E = m c^2}
\fi
\documentclass[border=2pt]{standalone}
\usepackage{amsmath}
\usepackage{varwidth}
\begin{document}
\begin{varwidth}{\linewidth}
\[ \formula \]
\end{varwidth}
\end{document}
There are other converters out there but you need not bother if you can use this.
I have to mention MathJax. It runs in a browser, via one-line JavaScript snippet. Should you ever migrate to a browser/mobile service this would be a perfect solution. Here is their one page tutorial.
I am a relatively new IPython Notebook user and I am using IPython 3.2.1. So upfront, my apologies if I did not read some documentation carefully!
I am trying to typeset some LaTeX in my Notebook intended for a presentation. I tried to utilize MathJax capabilities better than what's (supposedly) available by default and so tried incorporating other extensions that come with MathJax explicitly. In particular, I tried getting my IPython Notebook to load AMScd.js, AMSsymbols.js and unicode.js through the following sequence of steps:
Obtain the .js files for these extensions from the latest MathJax (v2.5) source
Add them to my ~/.ipython/nbextensions
Modify custom.js in ~/.ipython/profile_<mine>/static/custom by appending IPython.load_extensions("AMScd"), etc.
Now, all these work fine, and I am able to typeset commutative diagrams nicely in my IPython notebook. So, while at all this, I decided to also include/load AMSmath.js that comes along with MathJax and this is problematic. (To me, this seems like a natural thing to do given that other extensions work well!) However, attempting to include AMSmath.js via IPython.load_extensions("AMSmath") causes LaTeX math in my Notebook to display [Math Processing Error] everywhere. Here's my minimal example and the output with and without including IPython.load_extensions("AMSmath").
Markup:
## A minimal working example
\\[
\Delta u = f \text{ on } \Omega
\\]
(I would totally like to include images here, alas, my not being an active participant in the community here leaves me with not even 10 reputation!)
So, what am I missing here? Why is this inclusion of AMSmath problematic? Any help would be appreciated! Thanks!
It should work without extra configuration. Have a look here.
Your example in a markdown cell should be
(If you want the equation inline you can use $...$)
Inline equation $\Delta u = f \text{ on } \Omega$
(Or if you want the equation centered in their own line you can use $$...$$)
$$\Delta u = f \text{ on } \Omega$$
The result of both snippets in the same markdown cell is rendered as:
How it is loaded?
IPython/Jupyter notebook preloads some MathJax extensions including the extension you want to load. This extension is not an IPYthon/Jupyter extension so it shouldn't work if you try to load this MathJax extension as an IPython/Jupyter extension. See here to know more about how to load other MathJax extensions.
First time questioner and extremely new LaTeX user here. I'm trying to get equations to line up according to the arrow symbol used in my linear rules for a Phonology paper.
\begin{align}
\text{/b'al/} &\arrow\ \text{[b\super{j}\textipa{A}l]}\\
\text{/luna/} &\arrow\ \text{[wu.n\textipa{A}]}\\
\end{align}
For this I made \newcommand{\arrow}[0]{$\rightarrow$} to avoivd swapping in and out of mathmode.The format I'm trying to get is that it would have the first and second lines match up according to the arrow. However, I keep getting a "Missing } inserted. } l.38 \end{align}".
Sorry for the possibly dumb question, but can anyone help?
If you are using \arrow in both math and text mode, then you can use
\newcommand{\arrow}{\ensuremath{\rightarrow}}
which will ensure it be typeset in math-mode, regardless of the context. Note that there are some problems with using \ensuremath. However, they may not pertain to your situation.
It looks like the problem is that the align environment already defines math mode, and because your \arrow definition includes the math mode delimiters it breaks the whole thing. You just have to write \rightarrow without the $ ... $ around it.
If you want, define another command \marrow[0]{\rightarrow} to use within math mode.
If this answered your question, please mark it as such so that others know that it worked for you.
I'm currently trying to save a stress vs. strain curve using Octave. On this plot, I want to include text showing the equation for calculating engineering stress and engineering strain. Both of these require greek letters (\sigma and \epsilon respectively) as well as subscripts for the formulae.
Currently, using print with -deps, -dpng, or any other device, it creates a file, however the greek letters appear as the words "sigma" and "epsilon", and wherever I have a subscript, such as 0, it just appears as "_0". This looks very unprofessional.
Since I'm generating some 25 graphs, I don't want to have to go through and do a screenshot for each one. Does octave support saving the generated figure as displayed? I intend to use the generated files in a LaTeX document later (preferably as png so I can email them separately too).
I've also tried changing the "graphics_toolkit" option between fltk and gnuplot however it doesn't seem to help.
Attached to this post is a screenshot of the desired results and the actual results.
I am currently "not allowed" to post images, so I'll link them:
http://i.imgur.com/Tjt5Ecn.png (screenshot, desired result) and http://i.imgur.com/SP3hekd.png (directly saved, actual result)
Does anyone know a good way to print a figure from Octave which includes greek characters and subscripts in the titles?
Since you plan to use your graph in a Latex document, generating the graphs with -depslatex and converting them to pdf is a good idea . (Results look slightly better than direct -dpdflatex).
With -depslatex, you can include Latex code in your figures that will be written to a separate tex file.
Note that you need to use double backslashes \\ to export a single backslash.
graphics_toolkit("gnuplot");
...
legend("$\\varepsilon$");
print(sprintf("graph%s_%d.eps", name, type), '-depslatex', '-S200,270', '-F:9');
system(sprintf("epstopdf graph%s_%d.eps", name, type));
On the Latex side, you then \input the tex file generated by Octave. On the plus side, since you need 25 graphs, you can automatize this process on both sides Octave and Latex.
\newcommand{\mygraph}[1]{%
\graphicspath{{./figures/}}
\resizebox{0.495\linewidth}{!}{\relscale{1.0}\small%
\input{./figures/#1.tex}
}%
}
\mygraph{graph1_1}
Here, a Latex command \mygraph is defined to scale and include a figure located in a subfolder.
(I am using Octave 4.0.0 with gnuplot 4.4 on Ubuntu 12)
I am finishing my thesis and have a large appendix. Some tables only look good, if first done on a3 and then (paper)printed on a4. Anyhow, working all the files seperalty is fine, but I struggle to compile all in one.
I use the geometry package and start the document with:
\usepackage[a4paper,left=30mm,right=20mm,top=20mm, bottom=20mm]{geometry}
For the appendix, I want to include the table and use
\newgeometry{a3paper,left=25mm,right=15mm, top=15mm, bottom=15mm}
However, the command is completely ignored and I can read "a3paper,left=25mm,right=15mm, top=15mm, bottom=15mm" above the table.
What did I miss? Is it even possible? If not, how do I get the numbers right, if I have to include it as a pdf (which works)?
Thanks!
I don't think it's possible (at least if your output is DVI). Have a look at Change paper size in the middle of a latex document?.