liamoc / latex-formulae

Libraries and tools for rendering math to images using real LaTeX, from Haskell, Pandoc and Hakyll
BSD 3-Clause "New" or "Revised" License
56 stars 6 forks source link

Bottom part of tikzcd images is truncated #11

Open bgavran opened 4 years ago

bgavran commented 4 years ago

Hey, thanks for the great tool! I'm having some strange troubles when using tikzcd package in LaTeX for Hakyll.

Namely, using this code:

---
title: Test
preamble: \usepackage{tikz-cd}\usetikzlibrary{cd}

---

This is a test.

$$
\begin{tikzcd}[column sep=large] C \ar[r, bend left=18pt, "H"]\ar[r, bend right=18pt, "G"']\ar[r, phantom, "\scriptstyle\alpha\!\Downarrow\;"]& D \\
\end{tikzcd}
$$

---

$$
\begin{tikzcd}
F(X) \ar[r, "F(f)"]                & F(Y)\\
X    \ar[r, "f"] \ar[u, dashed] & Y \ar[u, dashed] \\
\end{tikzcd}
$$

Another text.

This is the output I'm receiving: Screenshot_20190908_225224

As you can notice, the bottom part of these images is missing. This doesn't seem to be happening for any old latex formulae, but just when I'm using tikzcd. If I add an empty line such as & \\ just before \end{tikzcd} then the problem seems to go away, but that messes up alignment if I'm using tikzcd inline. Everything else seems to be working properly, so it doesn't seem the problem is related to my code. I've found something potentially relevant: apparently convert truncates these images? https://imagemagick.org/discourse-server/viewtopic.php?t=36176

tmpethick commented 4 years ago

I had what seems to be a similar problem with tikzpicture. Wrapping it in a fbox solved the problem. In order to get rid of the border I used lfbox instead with a white background (add \usepackage{longfbox} to your preamble). Unfortunately we do need to draw something and a white border still shows a black line for some reason. Hopefully the following helps you if you haven't already figured it out:

$$\lfbox[border-width=0pt,background-color=white]{\begin{tikzpicture}[node distance=2cm and 2cm]
\node[state] (v1) {$X_1$};
\node[state] (v2) [below left =8mm and 50mm of v1] {$X_2$};
\node[state] (v3) [below right=8mm and 10mm of v1] {$X_3$};
\node[state] (v4) [below =100mm of v1] {$X_4$};
\path[-] (v1) edge node[label] {} (v2);
\path[-] (v1) edge node[label] {} (v3);
\path[-] (v4) edge node[label] {} (v2);
\path[-] (v4) edge node[label] {} (v3);
\end{tikzpicture}}$$