尝试让 TikZ 图表的两个节点中的“P”和“Q”排版在同一基线上

尝试让 TikZ 图表的两个节点中的“P”和“Q”排版在同一基线上

“Q” 显然排版时离灰色线段太远,而且它没有与“P”绘制在同一基线上。我之所以要命名一个节点,(auxiliary node for Q)是为了在放置字母时忽略“Q”的尾部。(此节点中的“O”应该在后续节点命令中被“Q”遮挡 - 尾部除外。)

\documentclass[10pt]{amsart}

\usepackage{mathtools,array}

\usepackage{tikz}
\usetikzlibrary{calc}





\begin{document}



\begin{center}
\begin{tikzpicture}



%Part of two ellipses and a parabola are drawn.
\draw (0,0) arc (0:90: 2 and 1);
\draw (0,0) arc (0:-72: 2 and 1);
\path node[anchor=east] at ({-2+sqrt(31)/8},-15/16){$E$};
\draw[fill] (0,0) circle (1.5pt);
%
\draw (3,0) arc (180:90: 2 and 1);
\draw (3,0) arc (180:252: 2 and 1);
\draw[fill] (3,0) circle (1.5pt);
%
\draw[domain=-1:4, smooth, variable=\x, blue] plot ({\x}, {-1/9*\x*\x + 1/3*\x});
\path node[anchor=south west, xshift=-0.5mm, yshift=-1mm] at (3.75,-5/16){$F$};
%
%A "pin" is drawn between (0,0) and its label.
\draw[draw=gray, line width=0.8pt, shorten <=1.5mm, shorten >=0mm] (0,0) -- ({(atan(1/3)+90)/2}:0.75);
\path node[anchor=south west] at ({(atan(1/3)+90)/2}:0.75){$P$};
%
%A "pin" is drawn between (3,0) and its label Q.
\draw[draw=gray, line width=0.8pt, shorten <=1mm, shorten >=1mm] (3,0) -- ($(3,0) +({(atan(-1/3)+180+90)/2}:0.75)$);
\path node[anchor=south east] (auxiliary node for Q) at ($(3,0) +({(atan(-1/3)+180+90)/2}:0.75)$){$O$};
\path node[anchor=north west] at (auxiliary node for Q.north west){$Q$};

\end{tikzpicture}
\end{center}


\end{document}

答案1

更新后续问题之后

使用和将节点Q与节点P基线对齐,并制作anchor=basebaseline={P.base}与灰线对齐。

埃

\documentclass[10pt]{amsart}

\usepackage{mathtools,array}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
        
    \begin{center}
        \begin{tikzpicture}         
            %Part of two ellipses and a parabola are drawn.
            \draw (0,0) arc (0:90: 2 and 1);
            \draw (0,0) arc (0:-72: 2 and 1);
            \path node[anchor=east] at ({-2+sqrt(31)/8},-15/16){$E$};
        
            \draw (3,0) arc (180:90: 2 and 1);
            \draw (3,0) arc (180:252: 2 and 1);

            \draw[domain=-1:4, smooth, variable=\x, blue] plot ({\x}, {-1/9*\x*\x + 1/3*\x});
            \path node[anchor=south west, xshift=-0.5mm, yshift=-1mm] at (3.75,-5/16){$F$};
            
            % put on top <<<<<<<
            \draw[fill] (0,0) circle (1.5pt);
            \draw[fill] (3,0) circle (1.5pt);
            
            %A "pin" is drawn between (0,0) and its label.
            \draw[gray, line width=0.8pt, shorten <=1.5mm, shorten >=0mm] (0,0) -- ({(atan(1/3)+90)/2}:0.75);
            %A "pin" is drawn between (3,0) and its label           
            \draw[gray, line width=0.8pt, shorten <=1mm, shorten >=1mm] (3,0) -- ($(3,0) +({(atan(-1/3)+180+90)/2}:0.75)$);
            
            \node(P)[anchor=south west, inner sep =0] at ({(atan(1/3)+90)/2}:0.75 ){$P$};
            \node(Q)[anchor=base, baseline={P.base}, inner sep =0] at ($(3,0) +({(atan(-1/3)+180+90)/2}:0.75)$) {$Q$};          

        \end{tikzpicture}   
    \end{center}        
        
\end{document}

相关内容