1

Per request, here is the image of mwe.pdf:

image of mwe.pdf

See below for my problem, discussion of problem, and copy of mwe.tex.


This is a difficult query to present because it necessarily involves inserting an aymptote box into a picture environment. Unfortunately, this is not an asymptote problem, so it must be presented in a LaTeX forum.

As discussed below, I (necessarily) use the picture environment to vertically align a minipage of free-form text with an asymptote diagram. Apparently(?), the picture environment moderately disrupts the horizontal positioning of the asymptote diagram with glue.

How do I prevent the disruption of the asymptote diagram's horizontal positioning?

Discussion

A minimum working example of the problem is presented below. asyboxa, which draws the 4 quadrants of a circle, is hard-coded to create a 4cm by 4cm diagram. boxa presents a 6cm wide minipage, with its text aligned to the bottom of boxa.

The preamble sets the unitlength of 1cm, which controls how coordinates are interpreted in the picture environment. The first framed picture environment combines the minipage with the asymptote diagram while the second framed picture environment only presents the asymptote diagram.

In both frames, the manually drawn square indicates where the asymptote diagram is intended to be placed. This can be confirmed by comparing the \put commands within each picture environment. As the generated PDF will show, both picture environments are vertically positioning the asymptote diagrams as intended, but are also (apparently) inserting unwanted glue that is disturbing the horizontal positioning.

Compile procedure:

  1. Save the file as (for example) mwe.tex
  2. Execute: pdflatex mwe.tex
  3. Execute: asy mwe-*.asy
  4. Execute: pdflatex mwe.tex

This should create mwe.pdf. The mwe.tex file is shown below.

\documentclass[fleqn,letterpaper,10pt]{article}
\pagestyle{plain}
\usepackage{asymptote}
\newsavebox{\boxa}
\newsavebox{\asyboxa}
\setlength{\unitlength}{1cm}

\begin{document}%

\begin{lrbox}{\asyboxa}%
\begin{asy}
size(4cm,4cm);
draw((-2,0) -- (2,0));
draw((0,-2) -- (0,2));
draw(circle((0,0), 2));
\end{asy}
\end{lrbox}%

\begin{lrbox}{\boxa}%
\begin{minipage}[b]{6cm}%
Minipage has 6cm width. \\%
Text alignment uses [b] option. \\%
Therefore last line of minipage \\%
is at bottom of boxa.
\end{minipage}%
\end{lrbox}%

\frame{%
\begin{picture}(11.5,4.5)
    \linethickness{.5mm}% 
    \put(0,0.2){\usebox\boxa}%
    \put(7.0,0.2){\usebox\asyboxa}%
        \put(7.0,0.2){\line(1,0){4.0}}%        
        \put(7.0,4.2){\line(1,0){4.0}}%
        \put(7.0,0.2){\line(0,1){4.0}}%
        \put(11.0,0.2){\line(0,1){4.0}}%
\end{picture}%
}%

\vspace*{36pt}%

\frame{%
\begin{picture}(5.5,4.5)
    \linethickness{.5mm}% 
    \put(1.0,0.2){\usebox\asyboxa}%
        \put(1.0,0.2){\line(1,0){4.0}}%        
        \put(1.0,4.2){\line(1,0){4.0}}%
        \put(1.0,0.2){\line(0,1){4.0}}%
        \put(5.0,0.2){\line(0,1){4.0}}%
\end{picture}%
}%

\end{document}

Addendum

Two additions to the query.

  1. I added the asymptote tag, since other asymptote users may have {struggled with -- solved} the problem.
  2. I experimented by defining the picture environment wide enough to extend the right side margin, defining a (very wide) savebox to contain the asymptote box flush left, and having the picture environment \put the savebox instead of the asymptote box -- No Joy.
epR8GaYuh
  • 2,432
user2661923
  • 185
  • 7
  • I'm not sure what you mean: you are defining a picture 5.5cm wide and 4.5cm high and place objects inside it. The stated bounding box is fully respected. – egreg Feb 23 '20 at 10:52
  • @egreg "The stated bounding box is fully respected." Yes, but within the bounding box, the picture environment is not placing the lower left hand corner of asyboxa at (1.0, 0.2), as it should. This disruption is verified by the picture environment's placing of the 4 line segments. – user2661923 Feb 23 '20 at 15:56
  • If I put your second picture environment in a \fbox with \fboxsep set to zero, adding \put(0,0){\circle*{0.1}} and \put(5.5,4.5){\circle*{0.1}} just to mark the bounding box, I get this picture (click). The Asymptote drawing sits exactly at (1,0.2). – egreg Feb 23 '20 at 16:15
  • @egreg First of all, thank you for your attention. I have two reactions, depending on what you are implying. Either (1) Wow, you have solved it. or (2) You have misinterpreted my intent. Please post your solution as an answer, **including the latex code, so that I can create my own pdf. see next comment – user2661923 Feb 23 '20 at 16:25
  • @ egreg . However, the point of this query is not to reproduce a quartered circle in the picture environment, but to do all of the drawing in asymptote (et al, e.g. pstricks, tikz, ...) and use the picture environment to precisely control the placement of the diagram. Therefore, I am looking for a solution (perhaps using fbox) that employs asyboxa – user2661923 Feb 23 '20 at 16:26
  • Why aren't you posting a picture for comparison? – egreg Feb 23 '20 at 17:01
  • @egreg "Why aren't you posting...?" Good point; I didn't realize how easy it is. I have updated the original query with an image of the resultant mwe.pdf. – user2661923 Feb 23 '20 at 18:48
  • OK, that's a known problem. On the other hand, newer TeX distributions should have a fixed asymptote.sty. – egreg Feb 23 '20 at 20:46
  • @egreg Please see the answer that I just posted. Thanks for your insight. – user2661923 Feb 23 '20 at 21:39

0 Answers0