Menu

#1 Issue with cropping using Qcircuit

1.0
closed
2020-09-12
2020-09-10
No

I'm experiencing an issue in which the beginning and end labels of qcircuit diagrams are clipped. For example, this code

% \documentclass{article}
\documentclass[border={0pt 1pt}]{standalone}
\usepackage{qcircuit}
\usepackage{amsmath}
\usepackage{mathtools}

\DeclarePairedDelimiter\ket{\lvert}{\rangle}

\begin{document}
\Qcircuit @C=1em @R=1em {
  \lstick{\ket{A}} & \ctrl{1} & \rstick{\ket{A}} \qw \\
  \lstick{\ket{B}} & \targ & \rstick{\ket{B\oplus A}} \qw
}
\end{document}

compiled with pdflatex file.tex, clips the beginning and terminal kets. If I use the article document class, or extend the border I can make the whole image appear. I've attached a PDF of the non-clipped, correct version. But I'm not sure how to attach 2 files or upload images, so I haven't included the clipped version. Basically, it cuts out the As, B, and B xor A. I'm using standalone 2018/03/26 v1.3a. Please let me know if you need any further information, etc. Thanks!

1 Attachments

Discussion

  • Matthew Huszagh

    Matthew Huszagh - 2020-09-10

    Here's the clipped version.

     
  • Martin Scharrer

    Martin Scharrer - 2020-09-10

    Hi Matthew, standaloneclipps to the official bounding box and some picture environments do not encount labels to their bounding boxes. There is nothing from within TeX what standalonecan do about it as it has no way to know where the ink is and not.

    Workarounds you can try:
    1. you could try to make Qcircuitproduce the correct bounding box. Maybe there is an option, but I actually doubt that.
    2. add a border using the border=<value> class option. This depends on the picture unfortunatly, i.e. needs manual work.
    3. the tool pdfcrop which should come with LaTeX uses ghostscript(might need extra installation) to get the actual bounding box of the whole PDF. That tool can look where the ink is.

    There might be a way to make standalonecall ghostscriptto get the bounding box, but that is tricky as it requires the whole PDF to be finished first. I had that idea a while ago, but it is not often required and can be fixed manually as shown above.

     
  • Martin Scharrer

    Martin Scharrer - 2020-09-10
    • labels: --> bounding box
    • assigned_to: Martin Scharrer
     
  • Matthew Huszagh

    Matthew Huszagh - 2020-09-10

    Thanks for such a quick response Martin. My setup is a bit unusual, so modifying Qcircuit to include text in the bounding box might actually be the easiest solution. In any event, this doesn't appear to really be an issue with standalone, so feel free to close this. Thanks for all the work you've put into this tool!

     
  • Martin Scharrer

    Martin Scharrer - 2020-09-12
    • status: open --> closed
     

Log in to post a comment.