2

Is there is any way to crop the output pdf to the \fbox{} with LaTeX Macros? I wrote a macro to test such examples something like:

\newcommand{\inlinebox}[1]{
\fbox{#1}%
<--crop the output page to the equation content-->
\clearpage%
}

Minimal example of LaTeX:

\documentclass{article}
\newcommand{\inlinebox}[1]{
\fbox{#1}%    
<--crop the output page to the equation content-->
\clearpage%
}
\begin{document}
\inlinebox{$\widetilde{\mathbf{l}}$}
\end{document}

Expected PDF output is something like:

enter image description here

I am facing some issues with preview package and I cannot also use standalone class so I need to wrote my own macro to handle such small tasks.

NOTE: I use latex dvips ps2pdf cycle.

1 Answer 1

2

Is this what you're looking for?

\documentclass{standalone}

\begin{document}

\fbox{$\widetilde{\mathbf{l}}$}

\end{document}

I leave some grey border to show that the generated PDF just contains the box

enter image description here

You can also do, but with not so nice output

\documentclass{article}

\begin{document}

\pagestyle{empty}
\fbox{$\widetilde{\mathbf{l}}$}

\end{document}

Then run

latex file.tex
dvips file.dvi -o
ps2pdf file.ps
pdfcrop file.pdf
4
  • thank you for your reply but i mentioned above that i cannot use standalone due to i have to follow the in house style of my organization. Dec 16, 2015 at 9:20
  • @MohamedSayed The output size cannot be controlled by a macro like that.
    – egreg
    Dec 16, 2015 at 9:22
  • ok i understand that but what is the alternative solution for that issue? what is your suggestions ? Dec 16, 2015 at 9:25
  • I am trying to use pdfcrop file.pdf but i got an error The Perl interpreter could not be found I downloaded it and installed but with no success. Dec 16, 2015 at 9:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .