
TikZ で円で囲んだテキストの垂直方向の配置に問題があります。この基本コードが問題の原因です。
\texttt{some text here =}
\tikz[remember picture] \node[draw,ellipse,fill=none,thick] (code) {\texttt{other text}};
問題は、表示されるテキスト「some text here=」が、表示されるテキスト「other text」と垂直に揃っていないことです。ドキュメントでアンカーについて読みましたが、有望に思えましたが、今のところうまく機能していません。左側をノードにすることで実現できるかもしれませんが、それは必要ないと思います。何かご提案があれば、ぜひお願いします。
答え1
base
オプションにはノードの を使用しますbaseline
。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\texttt{some text here =}
\tikz[remember picture,baseline=(code.base)] \node[draw,ellipse,fill=none,thick] (code) {\texttt{other text}};
\end{document}
編集者:クラウディオ・フィアンドリーノ
考えられる代替案は次のとおりです:
\documentclass[11pt,a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\texttt{some text here = \tikz[baseline=-0.825ex] \node[draw,ellipse,fill=none,thick] (code) {other text};}
\end{document}
tikz
最初の内部にコードを挿入すると、texttt
自動的にタイプライターでレンダリングされるため、ノード内のコマンドをスキップできることに注意してください。
答え2
\texttt{some text here =}
\tikz[remember picture,baseline]
\node[draw,ellipse,fill=none,thick,anchor=base] (code) {\texttt{other text}};