Bokeh does not handle Latex. A solution has been proposed: http://docs.bokeh.org/en/latest/docs/user_guide/extensions_gallery/latex.html#userguide-extensions-examples-latex
This is great for adding Latex on top of the canvas. Is there an easy way to use this strategy so we can use Latex in the axis labels?
Bokeh 2.4 adds support for LaTeX (and MathML) to some elements in Bokeh. Currently, you can use LaTeX on axis labels, tick labels, div widgets, and paragraph widgets. LaTeX support for more elements should be added soon. For more information about the new math text feature and how to use them, see the Bokeh 2.4 release blogpost, the new blackbody radiation example, and the Bokeh user guide!
Related
I have a series of markdown files that I am turning into slides using Pandoc and the Beamer template. I am creating my own custom Beamer template in order to format those slides.
pandoc --slide-level 2 -fmarkdown-implicit_figures -t beamer --template mytemplate.beamer -o test.pdf *.md
I am struggling with making certain elements look the way I would like them to.
My simplified markdown looks like this:
## Header
Normal Body Text
![Image](images/Image1.png "Image")
Specifically, my images are coming out left justified. I can't figure out how to get them to center. If I remove the -fmarkdown-implicit_figures option, then the images are properly centered, but includes captions that I don't want. Adding that flag eliminates the captions but also eliminates the centering.
At the same time, I want the normal body text to be centered as well. So in the above example I would like the text Normal Body Text to be centered. Again, I can't figure out how to do that. I have managed to center other elements (such as the header), but I can't find an appropriate name for the element that represents normal body text.
Can anyone offer a solution to either of these issues?
I found a way to center the images. It may not be the best option, but this seems to work:
\usepackage{letltxmacro}
% Save the meaning of \includegraphics
\LetLtxMacro\latexincludegraphics\includegraphics
% Update the include graphics command to include centering
\renewcommand{\includegraphics}[2][]{%
\centering
\latexincludegraphics[#1]{#2}}
To ensure the normal text was centered, I used the following, again I am unsure if this is the best way:
% Center Text By Default
\usepackage{ragged2e}
\centering
My question in short is: How can you create a boxed text with a label that can be referenced?
Background: I am generating LaTeX output from a Markdown document to be included in a larger LaTeX document. I would like to describe the steps of an algorithm as boxed text with a label that can be referenced. I know how to create a labeled figure and how to create boxed text, but I haven't been able to figure out how to combine the two, i.e. how to label the boxed text as if it was a figure, or how to include the text in a figure (other than converting it to an image, which I'd like to avoid).
An initial "solution": Just putting a the box and an empty figure next to each other (see below) kind of works, except that nothing ensures that the figure label won't float away from the box as I work on the document, since figures are floating objects while text boxes are part of the text, and the two are handled differently by LaTeX. Moreover, you may need to use LaTeX vertical space commands to make it look reasonably good, but it is hard to get it perfect. Is there a simple solution? Thanks!
P.S. I know that I could just switch to LaTeX and figure out a solution there, but here I am looking for a solution in Markdown, possibly making use of some embedded LaTeX commands.
You can see the algorithm in Figure \ref{methods:estimating}.
\fbox{\parbox{5in}{
1. Initialize $b_r=0$ for $r=1..R$ \\
2. For each item $i, i=1..U$, calculate ... \\
3. Re-estimate ... \\
4. Proceed to Step 2 until it converges.
}}
![Estimating ... \label{methods:estimating}]()
It is rendered like this:
You can use one of the packages for writing algorithms. See https://www.sharelatex.com/learn/algorithms.
So I am using the flashcard software Anki which uses LaTex for its math equation formatting
So when I write an equation with a fraction in the same line as standard text, it automatically allignts the lowest point of the equation, in the case the denomitor of the fraction, with the bottom the normal text. How can I get the equation and text to be horizontally aligned.
Some text before an equation: [$]\frac{x^2}{y}[/$]
What I did was to make the equation itself a bit smaller to better match the text around it.
To add it for all equations go to: Tools > Manage Note Types > Options > Header
Or you could place it inline: [$]\tiny[/$]
An excellent writeup on sizing text this way can be found at tex.stackexchange
And you may be able to get better results by changing the font itself.
As the LaTeX snippets are finally rendered as images, this is a CSS issue. The equations become centered when you add the following rule to your card CSS:
img[src*="latex"] {
vertical-align: middle;
}
This CSS rule matches all images whose file name contains the string latex and centers them in their respective line of text. It thus matches all anki-generated latex images.
If needed, I can supply info on how to edit the card CSS or on how to make Anki and Latex work together.
I have cells underneath figures in an ipython notebook that contain figure caption text. I would like them to be centre('center')-aligned. I use "< center >" in the markdown, which gives exactly the appearance I'm after in the notebook. But when nb-converting to latex, the text gets shunted over to the left.
So is there a way to get nbconvert to recognize text alignment in markdown cells when converting to latex?
Thanks.
You have actually asked two different questions:
is there a way to get nbconvert to recognize text alignment in markdown cells
figure caption (centering) in nbconvert
ad 1)
To convert the markdown to latex pandoc is used. Unfortunately, pandoc removes raw html from markdown if converted to latex (if also removes raw latex when converting markdown to html).
So it is not that straight forward to use html tags to format the output in both html and latex. This formatting may be achieved based cell metadata but that is not that trivial currently.
ad 2)
Nevertheless it is possible to create caption like text to work with html and latex.
Here we have to distinguish between caption for pyout or stream data (e.g. Ipython.display.Image) and markdown images.
pyout and stream
A possible approach is to create a Caption class like
class Caption():
def __init__(self,s):
self.s = s
def _repr_html_(self):
return '<center>{0}</center>'.format(self.s)
def _repr_latex_(self):
return '\\begin{center}\n'+self.s+'\n\\end{center}'
which is called after the image. Note that both should be called with the IPython.display.display method, e.g as oneliner
display(Image('image.jpg'),Caption('Figure Caption'))
This approach allows process the captiontext with python, e.g. to add figure numbers.
If you want to add such a caption to a matplotlib plot, it is a bit more tricky as the wrong ordering has to be overcome. A possible approach is to plot using this snippet
%matplotlib inline
plt.plot([1,2])
f=plt.gcf()
plt.close()
display(f,Caption('Plot'))
It may be noted the the default latex template of IPython 1.x doesn't play well with this approach, as here, image and caption are only loosely coupled and thus, vertical space might be included during latex compiling. The latex_basic template works much better. In IPython master the default templates are working fine.
markdown images
Markdown allows to use images like
![Caption](/files/image)
When converting to latex pandoc can take the Caption part and create a real latex caption.
Similar, when converting to html the caption gets embedded in a caption class to be easily styleable using css.
However, currently IPython requires a "/files/" prefix which is currently not removed, thus the image file won't be found by latex. (Fixed by now)
Be aware that these markdown image calls do not embed but only link the image into the ipynb file, therefore, the image has to remain available.
I'm looking for a way of linking box-like environments (e.g. minipages) in LaTeX, so that text that does not fit into the first box spills into subsequent boxes. E.g:
/begin{box-like-environment}
Text, too much to fit in this box...
/end{box-like-environment}
% some LaTeX here, possibly covering several pages...
/begin{box-like-environment}
% Text which doesn't fit in the first box should appear in this box
/end{box-like-environment}
The effect is something like the 'linked text boxes' of MS Publisher. Any ideas as to if and how this could be achieved?
The idea being, I guess, that the program figures out where to split the text between the two boxes, say so that you can have the text filled between two floats that face each other on opposite pages.
I have no idea how this might be done in Latex; Latex lacks sensitivity to page layout, so I'd guess it can't be done. Context is more sophisticated with regards to layout: it uses METAPOST to handle page layout, not primitive Tex, and there was discussion of something similar on the NTG mailing list: cf. Hans Hagen's post.
Maybe this is an option? There is some software for automatic translation of Latex to Context.
I have been alerted to the flowfram package, which does this.