diff --git a/layouts/shortcodes/katex.html b/layouts/shortcodes/katex.html
index b4bc605..559acb6 100644
--- a/layouts/shortcodes/katex.html
+++ b/layouts/shortcodes/katex.html
@@ -13,5 +13,6 @@
{{ cond (in .Params "display") "\\[" "\\(" -}}
{{- trim .Inner "\n" -}}
- {{- cond (in .Params "display") "\\]" "\\)" }}
+ {{- cond (in .Params "display") "\\]" "\\)" -}}
+{{- /* Drop trailing newlines */ -}}