1

How to automatically crop the white space (maximum thickness horizontal/vertical white border) around the formula in image, generated, say, by means of some of online LaTeX formula editors (actually I use EqualX standalone editor)?

For the formula:

n_i =
\begin{vmatrix}
p_1^1  & p_1^2  & \dots  & p_1^{i - 1} & 1      & p_1^{i + 1} & \dots  & p_1^D  \\
p_2^1  & p_2^2  & \dots  & p_2^{i - 1} & 1      & p_2^{i + 1} & \dots  & p_2^D  \\
\vdots & \vdots & \ddots & \vdots      & \vdots & \vdots      & \ddots & \vdots \\
p_D^1  & p_D^2  & \dots  & p_D^{i - 1} & 1      & p_D^{i + 1} & \dots  & p_D^D  \notag
\end{vmatrix}

There is an image created:

formula with border

I specially add the one-pixel black border at the edge of the image to illustrate, that there is a plenty of extra space, which is possible to cut off.

How to do it automatically (maybe by means of imagemagick utility)? There are a bunch of similar images for one-liner formulas, which I want to inline into html-text.

Are there useful commands, which can I prepend into preamble of document, that allows me to atchieve desired?

  • 4
    Use the standalone documentclass – Herr K. Jan 21 '15 at 19:16
  • If you want to use already existing pdfs, use the pdfcrop program. It can automatically remove white borders. – Juri Robl Jan 21 '15 at 19:20
  • By the way, if you want to embed math into html, you may want to check out MathJax. – Herr K. Jan 21 '15 at 19:22
  • Welcome to TeX.SX! – Adam Liter Jan 21 '15 at 19:26
  • @KevinC I can't use it in the blog I want. – Orient Jan 21 '15 at 19:31
2

Use the standalone document class:

MWE

\documentclass[border=2pt]{standalone}
\usepackage{mathtools}
\begin{document}
$
n_i =
\begin{vmatrix}
p_1^1  & p_1^2  & \dots  & p_1^{i - 1} & 1      & p_1^{i + 1} & \dots  & p_1^D  \\
p_2^1  & p_2^2  & \dots  & p_2^{i - 1} & 1      & p_2^{i + 1} & \dots  & p_2^D  \\
\vdots & \vdots & \ddots & \vdots      & \vdots & \vdots      & \ddots & \vdots \\
p_D^1  & p_D^2  & \dots  & p_D^{i - 1} & 1      & p_D^{i + 1} & \dots  & p_D^D  \notag
\end{vmatrix}
$
\end{document}

Output

enter image description here

  • Not works for me. But maybe the source of failure is invisible fields: in EqualX I can't manage whole the document completely. – Orient Jan 21 '15 at 19:29
  • I was mistaken. In the fact, there is a difference in images generated. – Orient Jan 21 '15 at 19:46
  • @Orient: So did my answer solve your problem? I'm confused by your comments... – Herr K. Jan 21 '15 at 20:30
  • Yes, your answer partially solve my problem (at least in a spirit of using TeX commands only). It is better if it being possible to remove white border completely (up to last pixel). – Orient Jan 22 '15 at 1:53
  • @Orient: Thanks. If you want to crop further, you may change the parameter of border to 1pt or even 0pt. – Herr K. Jan 22 '15 at 2:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.