
テキストに丸で囲んだ数字を入れたいので、Tiを使用しますけZソリューションを投稿しましたここただし、円とテキストをもう少し小さくしたいので、これを試しました。
\documentclass{article}
\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
\begin{document}
Numbers aligned with the text: \scriptsize{\circled{1}} end.
\end{document}
残念ながら、\scriptsize
中括弧は正しく閉じられているにもかかわらず、このコマンドの後のすべてのテキストが小さいため (テキスト内の「end」もスクリプト サイズ内です)、「リーク」しているように見えます。
\scriptsize
コマンドを「リーク」させずにこれを動作させるにはどうすればよいですか?
答え1
解決策は、フォント サイズを正しく変更することです。\scriptsize
は引数を取らず、その後のすべてのテキストのフォント サイズを変更します。 が中括弧で囲まれている場合 (たとえば、 の引数内\circled{·}
)、フォント サイズの変更はローカルのみになります。
変更されたコード:
\documentclass{article}
\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
\begin{document}
Numbers aligned with the text: \circled{\scriptsize1} \circled{1} end.
\end{document}
出力は次のようになります。
円のサイズを変更したい場合は、inner sep
AndréC のコメントに記載されているオプションの値を変更できます。
答え2
TikZには、LaTeXのさまざまなもの(テキスト、数式、表、画像など)を豊富なオプションで挿入できます。最も優れnode
たオプションの1つは、LaTeXのものよりもはるかに柔軟です:、、、、、、、、、、、scale
(\tiny
Stefan Kottwitzが言及しているかもしれません\scriptsize
)\footnotesize
\small
\normalsize
\large
\Large
\LARGE
\huge
\Huge
彼の答え)。
要約すると、この状況についてscale
考えてみましょう。node
\documentclass{article}
\usepackage{tikz}
\newcommand*\circled[2]{\tikz[baseline=(char.base)]{
\node[circle,draw,scale=#2,inner sep=2pt] (char) {#1};}}
\begin{document}
Numbers aligned with the text: \circled{1}{1} \circled{\color{blue} 1}{1.5} end.
\end{document}