jupyter-book
jupyter-book copied to clipboard
Fix tex macros in pdflatex build of docs
Originally posted by @chrisjsewell in https://github.com/executablebooks/jupyter-book/pull/952#issuecomment-689366919
Currently, the equation with the tex macros in is wrapped:
```{only} html
$$
A = \bmat{} 1 & 1 \\ 2 & 1\\ 3 & 2 \emat{},\ b=\bmat{} 2\\ 3 \\ 4\emat{},\ \gamma = 0.5
$$
```
This should be working with LaTeX though, because I added the macros to the preamble. But still I get an error: Package array Error: Empty preamble: 'I' used
, which I haven't got time to work out the issue right now.
@AakashGfude would you mind checking the docs and seeing why latex preamble
isn't getting passed through?
@chrisjsewell @mmcky the issue is not showing up now when I check it in jupyter-book
. Can anyone double-check.
Then we can close this issue.
@AakashGfude if I take away the only
directive which targets html
outputs I get the following tex
warning on #1167
! Package array Error: Empty preamble: `l' used.
See the array package documentation for explanation.
Type H <return> for immediate help.
...
l.7707 \end{split}
I see this is in the tex
\newcommand{\bmat}{\left[\begin{array}}
and these is the problematic lines
\begin{equation*}
\begin{split}
A = \bmat{} 1 & 1 \\ 2 & 1\\ 3 & 2 \emat{},\ b=\bmat{} 2\\ 3 \\ 4\emat{},\ \gamma = 0.5
\end{split}
\end{equation*}
I think this issue might be closeable as a red herring: the error reported relates to the matrix preamble, not the document preamble. I.e., one writes
\begin{array}{ll}
1 & 1
\end{array}
The part {ll}
, which specifies the horizontal alignment of each column, is also called a “preamble”. It must contain as many chars as there are columns in the array. Here, once the macros expand you get
\begin{array}{}
1 & 1
...
\end{array}
The message is telling that your preamble ({}
) is empty. Since the TeX processor can't look ahead and infer the number of required columns, it just guesses {l}
, and then promptly chokes on the rest of the input.
At least with the current Jupyter Book stack (jupyter-book 0.12.3), the macros specified in my preamble file work as expected.
As a side note: amsmath already provides \begin{bmatrix}
which does exactly what your \bmat
macro purports to do.