当 amsmath 符号接触时设置紧密的边界框

当 amsmath 符号接触时设置紧密的边界框

我希望直线的末端正好位于各个 的线上\circ。红色方框显示了为什么没有发生这种情况:\circ下方的空间比上方的空间大(请注意下方圆圈与圆圈末端的线条之间仍有空白。只需移除红色框即可检查这一点)。我尝试使用inner sep=-.75上部圆环和inner sep=-.3下部圆环,但这会使边界框切掉上部圆环的一部分,而下部圆环下方仍会留下空白。

如果您想知道为什么我使用\circ而不是绘制circle,答案是它\circ是文本并且不会随图像缩放(事实上我不希望它缩放!)。此外,我可以在行内引用这些符号,只需$\circ$每隔几行编写一次,而无需新的 tikzpicture。

MWE 如下

\documentclass{standalone}

\usepackage{xcolor}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{bm}
\usepackage{calc}
\usepackage{tikz}
%\usepackage{pbox}
\usetikzlibrary{decorations}
\usetikzlibrary{calc}
\usetikzlibrary{patterns}
\usetikzlibrary{shapes.arrows}
\usepackage{tikzscale}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}


\newcommand{\mat}{\mathbf}
\renewcommand{\vec}{\bm}

\begin{document}


   \begin{tikzpicture}

      %\useasboundingbox ($(1,-.5)-(.1,.2)$) rectangle ($(4,.5)+(.1,.2)$);

      \draw (1,0) -- (4,0); % linea centrale

      \foreach \x in {1,...,4} % ciclo sui cerchi
      {
         \draw (\x,0) -- +(0,.5);
         \node[black,draw=red,very thin,fill=white,inner sep=0] at (\x,.5) {$\circ$};
      }
      \foreach \x in {1.5,2.5,...,3.5} % ciclo sulle barrette
      {
         \draw (\x,0) -- +(0,-.5);
         \node[black,draw=red,very thin,fill=white,inner sep=0] at (\x,-.5) {$\circ$};
      }
      %\node[left] at (2.5,-.5) {1};

      %\draw[dashed,red] (current bounding box.south west) rectangle (current bounding box.north east);
   \end{tikzpicture}


\end{document}

答案1

问题是的底部\circ高于基线。您可以使用 来提高基线\raisebox,也可以使用包\Circle中的wasysym

\documentclass{standalone}

\usepackage{xcolor}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{bm}
\usepackage{wasysym}
\usepackage{calc}
\usepackage{tikz}
%\usepackage{pbox}
\usetikzlibrary{decorations}
\usetikzlibrary{calc}
\usetikzlibrary{patterns}
\usetikzlibrary{shapes.arrows}
\usepackage{tikzscale}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}


\newcommand{\mat}{\mathbf}
\renewcommand{\vec}{\bm}
\newcommand{\mycirc}{\raisebox{-.11ex}[\dimexpr\height-.11ex][0pt]{$\circ$}}

\begin{document}

   \begin{tikzpicture}

      %\useasboundingbox ($(1,-.5)-(.1,.2)$) rectangle ($(4,.5)+(.1,.2)$);

      \draw (1,0) -- (4,0); % linea centrale

      \foreach \x in {1,...,4} % ciclo sui cerchi
      {
         \draw (\x,0) -- +(0,.5);
        \node[black,draw=red,very thin,fill=white,inner sep=0] at (\x,.5) {\Circle};
      }
      \foreach \x in {1.5,2.5,...,3.5} % ciclo sulle barrette
      {
         \draw (\x,0) -- +(0,-.5);
        \node[black,draw=red,very thin,fill=white,inner sep=0] at (\x,-.5) {\Circle};
      }
      %\node[left] at (2.5,-.5) {1};

      %\draw[dashed,red] (current bounding box.south west) rectangle (current bounding box.north east);
   \end{tikzpicture}


\end{document}

\圆圈替换

相关内容