3

This is a continuation of my question.

Now when I work with it, it seems to me that this code produces the label letters that are slightly bigger that the corresponding letters in the text formulas (Say, look at the letter A in the in-line formula, in the caption - these looks the same, and letter A the label of the vetrex A - this one looks bigger for me).

enter image description here

Question: How to make them the same?

In general: How to make the labels on the picture of the same size as in the text?

It is obvious (for me), that the problem is in the way how the function opendot works, but neither @Charles Staats (who suggested it and helped me a lot), nor me understand how it works.


Restrictions:

  1. The option to scale the picture must be preserved. Sometimes I need to scale the picture, this shouldn't affect the labels - all of them have to be the same (and equal the letters in the main text formulas) regardless of the picture size.
  2. The points have to stay "empty". This is the entire three volume book design, which I really want to preserve.
  3. The graphics has to stay vector. Therefore,
 settings.prc = false;  // IMPORTANT
 settings.render = 0;   // IMPORTANT

is really important. So, please no solutions with the entire picture with labels change.

The ability to change the picture has to stay, the labels has always be the same as in the body text.

Thank you.

MWE:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[OT1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[pdftex]{graphicx}
\usepackage{euler,beton}
\usepackage[inline]{asymptote}

%============================================================
\begin{document}
Triangle $ABC$.



\begin{figure}[h]
    \centering
    \caption{Triangle $ABC$.}\label{OrthoCenterTetr}
    \begin{asy}
    settings.outformat = "pdf";
    settings.prc = false;  // IMPORTANT
    settings.render = 0;   // IMPORTANT
    import three;
    import geometry;
    texpreamble("\usepackage{euler,beton}");
%============================================================   
    void opendot(picture pic=currentpicture, triple v, material p=currentpen,
    light light=nolight, string name="", render render=defaultrender)
    {
    pen q=(pen) p;
    pen fillpen = light.background;
    if (invisible(fillpen)) fillpen = currentlight.background;
    if (invisible(fillpen)) fillpen = white;
    real size=0.5*linewidth(dotsize(q)+q);
    pic.add(new void(frame f, transform3 t, picture pic, projection P) {
    triple V=t*v;
    assert(!is3D(), "opendot() not supported unless settings.prc == false and settings.render != 0");
    if(pic != null)
    dot(pic,project(V,P.t),filltype=FillDraw(fillpen=fillpen, drawpen=q));
    },true);
    triple R=size*(1,1,1);
    pic.addBox(v,v,-R,R);
    }
%============================================================   
    void opendot(picture pic=currentpicture, Label L, triple v, align align=NoAlign,
    string format=defaultformat, material p=currentpen,
    light light=nolight, string name="", render render=defaultrender)
    {
    Label L=L.copy();
    if(L.s == "") {
    if(format == "") format=defaultformat;
    L.s="("+format(format,v.x)+","+format(format,v.y)+","+
    format(format,v.z)+")";
    }
    L.align(align,E);
    L.p((pen) p);
    opendot(pic,v,p,light,name,render);
    label(pic,L,v,render);
    }
%============================================================   
    size(4cm, 0);
    currentprojection=orthographic((5,2,3));

    real a=3;
    real b=4;
    real c=4;

    triple A=(0,0,a);
    triple B=(0,b,0);
    triple C=(c,0,0);

    draw(A--B--C--A,linewidth(1));
    draw(O--A^^O--B^^O--C,dashed);

    path3 p=O--(6,6*c/b,0);
    path3 q=B--C;
    path3 p1=O--(6,0,6*c/a);
    path3 q1=A--C;

    triple H1=intersectionpoint(p,q);
    triple H2=intersectionpoint(p1,q1);

    path3 h1=A--H1;
    path3 h2=B--H2;
    triple H=intersectionpoint(h1,h2);

    draw(h1);
    draw(h2);
    draw(O--H,dashed);
    opendot(Label("$H_2$",align=NW),H2);
    opendot(Label("$H_1$",align=SE),H1);
    opendot(Label("$H$",align=NE),H);
    opendot(Label("$A$",align=N),A);
    opendot(Label("$B$",align=E),B);
    opendot(Label("$C$",align=SW),C);
    opendot(Label("$O$",align=0.7S+0.3E),O);

    \end{asy}
\end{figure}

\end{document}
2
  • This is quite weird. I tested on a 2D asy picture. Label $A$ in the asy picture is bigger than $A$ outside the asy picture, while no scaling. A kind of default ?
    – Black Mild
    Commented Jan 30, 2020 at 18:52
  • 4
    Have you tried playing with the asy font size? E.g., defaultpen(fontsize(10)); is an Asymptote command to set the font to 10 points (or 10 bp, I don't remember which). Ideally this should be taken care of by the inline option you are using, but perhaps you can add it manually. Commented Jan 30, 2020 at 19:28

2 Answers 2

5

Charles Staats is correct. Using the same fontsize in documentclass and tell Asymptote that size for defaultpen, then the labels on the Asymptote picture of the same size as in the text.

enter image description here

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[OT1]{fontenc}
\usepackage{amsmath,amsfonts,amsthm,amssymb}
%\usepackage[pdftex]{graphicx}
\usepackage{euler,beton}
\usepackage[inline]{asymptote}
%============================================================
\begin{document}
In \LaTeX\ document, using the same fontsize in \verb|documentclass| and tell Asymptote that size for \verb|defaultpen|  in a Asymptote picture, say drawing a triangle $ABC$.
\begin{figure}[h]
\centering
\caption{Triangle $ABC$}\label{OrthoCenterTetr}
\begin{asy}
defaultpen(fontsize(12pt));
unitsize(1cm);
pair B=(-4,0), C=(1,0), A=(0,3.5);
pair M=(C+B)/2;
draw (A--M,green);
draw (A--B--C--cycle,orange);
label("$B$",B,SW);
label("$C$",C,SE);
label("$A$",A,N);
label("$M$",M,S);
\end{asy}
\end{figure}

Then the labels on the Asymptote picture of the same size as in the text: $A$ in the triangle $ABC$ and $A$ in Figure \ref{OrthoCenterTetr} have the same size.
\end{document}
1
  • This works for 2D but not for 3D. For some reason, the inline option does not agree with the document class option even despite of defaultpen(fontsize(12pt)). However the answer below works. Commented Feb 19, 2020 at 16:34
0

Previous answer works for 2D. For 3D I needed to add:

  1. [10 pt] option in the documentclass
  2. defaultpen(fontsize(10pt)); in the asymptote environment AND (ta-da-da-da...)
  3. \usepackage{asypictureB} as suggested here

The combination of these three approaches does provide same size font in the diagrams as in the text. Thanks everyone.

You must log in to answer this question.

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