Render LaTeX left aligned

Is there a way I can get the LaTeX to render as left aligned instead of at the center of the page in Pluto?

Embed the latex equations in markdown text?

Well that wouldn’t be a very useful option. I am trying to maybe use Pluto for professional calc packages and having to rewrite the equations would kind of end the reasoning on using it. I can maybe deal with center-alignment but I am used to things being left aligned (and mostly everyone here at the company as well). Here is what is returned that gets automatically rendered in pluto and jupyter. Only in jupyter, it is left aligned.

Pluto

Jupyter

image

Do you know if getting it to render as left aligned is possible in Pluto?

Well I think Pluto output cells center their content by default. In principle it is very easy to customize the look of Pluto because it’s just some CSS and you can actually add to that by writing CSS into a cell and executing it (which I don’t really understand how it works but it’s amazing). So if you are fine with all result cells being left-aligned (not just LaTeX) then you can probably fiddle the CSS :slight_smile:

For that you need to poke around the HTML a bit using Developer Tools (F12 in Firefox/Chrome), play a bit with the styles and if you found something that works for you, you can put it in a cell like

html"""
<style>
/* Your customization here */
</style>
"""
1 Like

Indeed as @abraemer suggested CSS is the way to go here.
You could override the display of all mathjax in your current notebook with the following style:

html"""
<style>
	mjx-container {
		text-align: left !important;
	}
</style>
"""

To have something more custom just for handcalcs you could create a custom struct wrapper around the LaTeXString struct that has a custom show method for MIME"text/html" that gives a specific class (as example) to your custom struct when shown within Pluto.

For this you could use as example AbstractPlutoDingetjes.is_inside_pluto(io::IO) which has exactly that as one of its use cases

4 Likes

This is great! Thanks!

I will experiment with both!

How did you get html syntax highlighting (shown below) in pluto?

image

It’s a hidden experimental feature that is not (anymore) on by default as it has performance issues in some cases.

You can enable it by opening the developer console in the browser while inside a Pluto notebook and type PLUTO_ENABLE_CM_MIXED_PARSER() to toggle it.
It is stored in the browser local cache so once you activate it, it will remain active on the same domain (e.g. localhost:1234) even when closing and reopening browser or pluto server and until you deactivate it with the same command.

You can read something more about the issues that made it not enabled by default here

1 Like