\multicolumn alternative in KaTeX - alignment

I want to be able to align a single cell's contents differently from the rest. I've found that this can be done using \multicolumn in LaTeX however, I have yet to find an alternative that works in KaTeX. Below is roughly what my current table looks like. Say that I want to align the cell with "Hello" to the right, how would I go about that in KaTeX?
\begin{array}{|l|}
\hline
\text{Hi} \\
\hline
\text{Good Morning} \\
\hline
\text{Hello} \\
\hline
\text{Howdy} \\
\hline
\end{array}

Indeed in KaTeX you can't do all that you can do in LaTeX, even using a tabular environment is not trivial.
As long as your array or table must only conain text, I would rely on html <table> tag and CSS style:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Array?</title>
<style>
table,td{border:1px solid black;border-collapse:collapse}
td.cellle,td.cellri{padding:5px}
td.cellri{text-align:right}
</style>
</head>
<body>
<table>
<tr><td class="cellle">Hi</td></tr>
<tr><td class="cellle">Good Morning</td></tr>
<tr><td class="cellri">Hello</td></tr>
<tr><td class="cellle">Howdy</td></tr>
</table>
</body>
</html>
table,td{border:1px solid black;border-collapse:collapse}
td.cellle,td.cellri{padding:5px}
td.cellri{text-align:right}
<table>
<tr><td class="cellle">Hi</td></tr>
<tr><td class="cellle">Good Morning</td></tr>
<tr><td class="cellri">Hello</td></tr>
<tr><td class="cellle">Howdy</td></tr>
</table>
Also, if it is needed, you can then use the KaTeX inline math delimiters within any single cell, whose alignment you control by the CSS.

Related

Pandoc Citeproc doesn't work on HTML format

I'm trying to reference cites from the .bib file in the HTML but without success. The function perfectly works for Markdown, so my question is does the citeproc work on other formats except for MD?
Here are some examples which I use:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="en">
<body>
Test [#test1]
</body>
</html>
Command: pandoc --bibliography=test.bib --citeproc test.html -o test.html -s --metadata-file=test.yaml
The .bib file contains the following:
#article{test1,
author = {Rathod, N and Kulawik, P and Ozogul, Y and Ozogul, F and Bekhit, A},
title = {Recent developments in non-thermal processing for seafood and seafood products: cold plasma, pulsed electric field and high hydrostatic pressure},
journal = {International Journal of Food Science & Technology},
date = {2022},
year = {2022},
pages = {774--790},
volume = {57},
number = {2},
doi = {10.1111/ijfs.15392},
raw = {Rathod, N. B., Kulawik, P., Ozogul, Y., Ozogul, F., & Bekhit, A. E. D. A. (2022). Recent
developments in non-thermal processing for seafood and seafood products: cold plasma, pulsed
electric field and high hydrostatic pressure. International Journal of Food Science &
Technology, 57(2), 774-790. https://doi.org/10.1111/ijfs.15392}
}
I have created the Lua filter which covers only partial cases. I'm a newbie in Lua and can not currently make the complex filter as we have it for MD.
Thank you.

Left Align lines of multi-line MathJax

I have a set of equations where I want the first two lines to be left aligned and the remaining right align. I have the right alignment working but I cannot figure out how to get the first two equations to left align. I am using the latest MathJax (3.1.0) and Hugo (v0.78.2-959724F0 windows/amd64)
Note: This question does not address this. That formats ALL MathJax to the left of a page. I just need these two lines to align left.
$$
Maximize: 5.00 x_{1} + 7.50 x_{2} \\\\
Subject\ to: \\\\
\begin{align}
x_{1} \leq& 200 \\\\
x_{2} \leq& 300 \\\\
1.0x_{1} + 1.5x_{2}\leq& 650 \\\\
x_{1}, x_{2} \geq& 0
\end{align}
$$
Displays this:
But I want it to look like this:
I found that you really need to separate it into two sections to have two different align sections:
$$
\begin{align}
& \text{Maximize: } 5.00 x_{1} + 7.50 x_{2} \\
& \text{Subject to:} \\
\end{align}
$$
$$
\begin{align}
&x_{1}& &\leq200 \\
&&x_{2} &\leq 300 \\
1.0&x_{1} + &1.5x_{2}&\leq 650 \\
&&x_{1}, x_{2} &\geq0
\end{align}
$$
Will render this (you may need to double the \ depending on your environment to get newlines to work):
Just to share ideas: Why not an HTML-table approach?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MathJax</title>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax#3/es5/tex-mml-chtml.js"></script>
<style>
td.tdleftc{text-align:center;min-width:80px}
td.tdleftl{text-align:left;min-width:80px}
td.tdright{text-align:right}
</style>
</head>
<body>
<table>
<tr><td class="tdleftl">Maximize:</td><td class="tdright">\(5.00\,x_1 + 7.50\,x_2\)</td></tr>
<tr><td class="tdleftl">Subject to:</td><td class="tdright"></td></tr>
<tr><td class="tdleftc">\(x_1\)</td><td class="tdright">\(\leq 200\)</td></tr>
<tr><td class="tdleftc"></td><td class="tdright">\(x_2 \leq 300\)</td></tr>
<tr><td class="tdleftc">\(1.0\,x_1 +\)</td><td class="tdright">\(1.5\,x_2 \leq 650\)</td></tr>
<tr><td class="tdleftc"></td><td class="tdright">\(x_1, x_2 \geq 0\phantom{00}\)</td></tr>
</table>
</body>
</html>
I feel that the content we are discussing would fit better in a tabular layout rather than in an math environment: since here we somehow embed one markup into another, I would leave the LaTeX syntax to the single cells and even style (align) the content of each cell by using CSS.

How to use Latex in dev.to editor?

I wonder is there some way I could render math formulas in dev.to editor to show as mathematical equations in my articles?
It seems that Dev.to supports Katex for mathematical formulas.
From dev.to documents:
KaTeX Embed
Place your mathematical expression within a KaTeX liquid block, as follows:
{% katex %} c = \pm\sqrt{a^2 + b^2} {% endkatex %}
To render KaTeX inline add the "inline" option:
{% katex inline %} c = \pm\sqrt{a^2 + b^2} {% endkatex %}
Info taken also for dev.to github issues.

Change HAML indentation from 2 to 4 spaces

Is there a way to change the indentation from 2 spaces to 4 spaces for HAML on a Ruby on Rails application?
If I failed to indent properly, I get: The line was indented 2 levels deeper than the previous line.
Taken from http://haml.info/docs/yardoc/#indentation
Haml’s indentation can be made up of one or more tabs or spaces.
However, indentation must be consistent within a given document. Hard
tabs and spaces can’t be mixed, and the same number of tabs or spaces
must be used throughout.
Here's my test:
test.haml
#content
.title
%h1 Test
Results:
haml test.haml
<div id='content'>
<div class='title'>
<h1>Test</h1>
</div>
</div>

Display latex table/tabular in Jupyter with latex cell magic

According to this Rich Display System example the Jupyter notebook can display latex using the %%latex cell magic.
The example given using the align environment works fine on my system (Notebook Server 3.2.0-8b0eef4) but when I try and show a tabular or a table, the result is just nicely typesetting Latex code!
Is there some kind of preamble I need to add to make this work?
Answer
Jupyter builds on MathJax and cite "MathJax doesn't implement tabular". The link also shows the recommended array environment as tabular replacement.
Workaround:
Latex can also be used in Markdown cells (Celltype Markdown instead of Code). You can select the left area besides the cell and press "m" key or via Cell>Cell-Type in top menu. Then you could use html for the table.
<table>
<tr>
<td>
\begin{eqnarray}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\end{eqnarray}
</td>
<td>
\begin{eqnarray}
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{eqnarray}
</td>
</tr>
</table>
Markdown cells are rendered so you don't see the code that generates the rendered latex. Instead you just see the rendered version until you double click it.
Plus you have the option of Markdown tables

Resources