带有表格 TikZ 的溢出 \hbox

带有表格 TikZ 的溢出 \hbox

在 TeXnicCenter 中编译我的 .tex 文件,

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{tikz}

\usetikzlibrary{arrows.meta,decorations.markings}

\tikzset{->-/.style={semithick,decoration={
        markings,
        mark=at position .52 with {\arrow{Stealth[length=2.5mm]}}},
        postaction={decorate}}}

\tikzset{--<--/.style={semithick,decoration={
        markings,
        mark=at position .28 with {\arrow{Stealth[length=2.5mm]}}},
    postaction={decorate}}}


\begin{document}

\begin{tabular}{cp{1cm}c}
$A_1=\begin{pmatrix}
1 & 1 \\
1 & 1
\end{pmatrix}$; &  &  
$\Gamma(A_1)\equiv \;\;\;\;\;$  

\begin{minipage}{1cm}

\begin{tikzpicture}[scale=0.725]

    \coordinate [label=below left:$P_1$] (p1) at (0,0);
    \coordinate [label=below right:$P_2$] (p2) at (6cm,0);

    \filldraw (p1) circle [radius=0.08cm]
              (p2) circle [radius=0.08cm];

    \draw[->-] (0,0) to [bend left] (6cm,0);

    \draw[->-] (p1) to [bend left] (p2);

    \draw[->-] (p2) to [bend left] (p1);

    \draw[--<--,rotate=60] (p2) arc (360:0:-1cm and -0.5cm);

    \draw[--<--,rotate=120] (p1) arc (0:360:-1cm and -0.5cm);

\end{tikzpicture}

\end{minipage}

\end{tabular}


\end{document}

您会得到 1 个坏盒子,并且在 Build Output 中出现以下消息:

pdflatex> Overfull \hbox (147.05411pt to wide) in paragraph at line 50--51

我怎样才能在不删除表格的情况下摆脱它们?

在此处输入图片描述

答案1

我认为您不需要迷你页面。正如 Zarko 所指出的,投诉是因为迷你页面不够宽,无法容纳图片。

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{tikz}

\usetikzlibrary{arrows.meta,decorations.markings}

\tikzset{->-/.style={semithick,decoration={
        markings,
        mark=at position .52 with {\arrow{Stealth[length=2.5mm]}}},
        postaction={decorate}}}

\tikzset{--<--/.style={semithick,decoration={
        markings,
        mark=at position .28 with {\arrow{Stealth[length=2.5mm]}}},
    postaction={decorate}}}


\begin{document}

\begin{tabular}{cp{1cm}c}
$A_1=\begin{pmatrix}
1 & 1 \\
1 & 1
\end{pmatrix}$; &  &  
$\Gamma(A_1)\equiv \;\;\;\;\;$  

%\begin{minipage}{1cm}

\begin{tikzpicture}[scale=0.725,baseline=(p1)]

    \coordinate [label=below left:$P_1$] (p1) at (0,0);
    \coordinate [label=below right:$P_2$] (p2) at (6cm,0);

    \filldraw (p1) circle [radius=0.08cm]
              (p2) circle [radius=0.08cm];

    \draw[->-] (0,0) to [bend left] (6cm,0);

    \draw[->-] (p1) to [bend left] (p2);

    \draw[->-] (p2) to [bend left] (p1);

    \draw[--<--,rotate=60] (p2) arc (360:0:-1cm and -0.5cm);

    \draw[--<--,rotate=120] (p1) arc (0:360:-1cm and -0.5cm);

\end{tikzpicture}

%\end{minipage}

\end{tabular}


\end{document}

在此处输入图片描述

实际上我也不会使用表格。我添加了一些其他功能,其中一些是 Zarko 建议的(谢谢!)。

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{tikz}

\usetikzlibrary{arrows.meta,decorations.markings}

\usetikzlibrary{bending} %< added
\tikzset{% inspired by https://tex.stackexchange.com/a/316050/121799
    arc arrow/.style args={%
    to pos #1 with length #2}{
    decoration={
        markings,
         mark=at position 0 with {\pgfextra{%
         \pgfmathsetmacro{\tmpArrowTime}{#2/(\pgfdecoratedpathlength)}
         \xdef\tmpArrowTime{\tmpArrowTime}}},
        mark=at position {#1-\tmpArrowTime} with {\coordinate(@1);},
        mark=at position {#1-2*\tmpArrowTime/3} with {\coordinate(@2);},
        mark=at position {#1-\tmpArrowTime/3} with {\coordinate(@3);},
        mark=at position {#1} with {\coordinate(@4);
        \draw[-{Stealth[length=#2,bend]}]       
        (@1) .. controls (@2) and (@3) .. (@4);},
        },
     postaction=decorate,
     }
}


\tikzset{->-/.style={semithick,arc arrow={to pos 0.52 with length 2.5mm}}}

\tikzset{--<--/.style={semithick,arc arrow={to pos 0.28 with length 2.5mm}}}
\begin{document}

\[
A_1=\begin{pmatrix}
1 & 1 \\
1 & 1
\end{pmatrix} \quad\text{with}~
\Gamma(A_1)\equiv \quad
\begin{tikzpicture}[scale=0.725,baseline=(p1)]
    \coordinate [label=below left:$P_1$] (p1) at (0,0);
    \coordinate [label=below right:$P_2$] (p2) at (6cm,0);
    \filldraw (p1) circle [radius=0.08cm]
              (p2) circle [radius=0.08cm];
    \draw[->-] (p1) to [bend left] (p2);
    \draw[->-] (p1) to [bend left] (p2);
    \draw[->-] (p2) to [bend left] (p1);
    \draw[--<--,rotate=60] (p2) arc (360:0:-1cm and -0.5cm);
    \draw[--<--,rotate=120] (p1) arc (0:360:-1cm and -0.5cm);
\end{tikzpicture}
\]

\end{document}

在此处输入图片描述

使其居中其他选项tikzpicture包括将其包装到 中\vcenter{\hbox{...}}

相关内容