使用图片环境定位/居中图表

使用图片环境定位/居中图表

我刚刚贴了一些 Dynkin 图(已经感谢你们了 :))但是它似乎对于页面来说太大了,因此没有居中,如代码所示:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgf} 
\usetikzlibrary{tikzmark}
\usetikzlibrary{positioning}
\usetikzlibrary{patterns,arrows,decorations.pathreplacing}
\begin{document}

test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test 

\vspace{1cm}

\begin{tabular}{cc}
$A_n$&
\begin{picture}(7,2)(0,0)

\put(0,1){\tikzmark{z}\circle*{3}}
\put(0,1){\line(1,0){20}}
\put(20,1){\circle*{3}}

\put(25,-1.5){\mbox{$\cdots$}}

\put(42,1){\tikzmark{t}\circle*{3}}
\put(42,1){\line(1,0){20}}
\put(62,1){\tikzmark{zg}\circle*{3}}
\put(62,1){\line(1,0){20}}
\put(82,1){\tikzmark{za}\circle*{3}}

\put(87,-1.5){\mbox{$\cdots$}}

\put(104,1){\tikzmark{zb}\circle*{3}}
\put(104,1){\line(1,0){20}}
\put(124,1){\tikzmark{zh}\circle*{3}}
\put(124,1){\line(1,0){20}}
\put(144,1){\circle*{3}}

\put(149,-1.5){\mbox{$\cdots$}}
\put(165,-1.5){\mbox{$\cdots$}}

\put(183,1){\circle*{3}}
\put(183,1){\line(1,0){20}}
\put(203,1){\circle*{3}}
\put(203,1){\line(1,0){20}}
\put(223,1){\tikzmark{zc}\circle*{3}}

\put(228,-1.5){\mbox{$\cdots$}}

\put(245,1){\tikzmark{zd}\circle*{3}}
\put(245,1){\line(1,0){20}}
\put(265,1){\circle*{3}}
\put(265,1){\line(1,0){20}}
\put(285,1){\tikzmark{ze}\circle*{3}}

\put(290,-1.5){\mbox{$\cdots$}}

\put(307,1){\circle*{3}}
\put(307,1){\line(1,0){20}}
\put(327,1){\tikzmark{zf}\circle*{3}}

\put(62,1){\circle{7}}
\put(124,1){\circle{7}}
\put(203,1){\circle{7}}
\put(265,1){\circle{7}}



  \end{picture}

 \begin{tikzpicture}[remember picture, overlay]
\draw [decorate,decoration={brace,amplitude=5pt,mirror},xshift=0.4pt,yshift=-0.4pt]({pic cs:z})+(-0.1pt,-3pt) coordinate (c) -- (c -| {pic cs:t}) node[black,midway,yshift=-0.4cm] {\footnotesize $y-1$};


\draw [decorate,decoration={brace,amplitude=5pt,mirror},xshift=0.4pt,yshift=-0.4pt]({pic cs:za})+(-0.1pt,-3pt) coordinate (c) -- (c -| {pic cs:zb}) node[black,midway,yshift=-0.4cm] {\footnotesize $z-1$};


\draw [decorate,decoration={brace,amplitude=5pt,mirror},xshift=0.4pt,yshift=-0.4pt]({pic cs:zc})+(-0.1pt,-3pt) coordinate (c) -- (c -| {pic cs:zd}) node[black,midway,yshift=-0.4cm] {\footnotesize $t-1$};

\draw [decorate,decoration={brace,amplitude=5pt,mirror},xshift=0.4pt,yshift=-0.4pt]({pic cs:ze})+(-0.1pt,-3pt) coordinate (c) -- (c -| {pic cs:zf}) node[black,midway,yshift=-0.4cm] {\footnotesize $x-1$};


\end{tikzpicture}
\end{tabular}

\end{document}

我想知道是否可以将它置于中央,使它向左移动一点并居中,即使它比应有的稍微大一点。

答案1

我将 括tabular在 中{\centering\noindent\makebox[20pt]{...}}。它使 makebox 居中。通常,makebox 的宽度为 0pt(允许左右边距对称出血),但由于您的叠加,图像略微偏离中心。允许表格在 20pt 框上居中解决了偏移问题。

而且,正如 egreg 指出的那样,需要在图像后添加垂直间隙,以避免与后续文本重叠。\vspace{1cm}例如, 就足够了。

\documentclass{article}
\usepackage{tikz}
\usepackage{pgf} 
\usetikzlibrary{tikzmark}
\usetikzlibrary{positioning}
\usetikzlibrary{patterns,arrows,decorations.pathreplacing}
\begin{document}

test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test 

\vspace{1cm}

{\centering\noindent\makebox[20pt]{
\begin{tabular}{cc}
$A_n$&
\begin{picture}(7,2)(0,0)

\put(0,1){\tikzmark{z}\circle*{3}}
\put(0,1){\line(1,0){20}}
\put(20,1){\circle*{3}}

\put(25,-1.5){\mbox{$\cdots$}}

\put(42,1){\tikzmark{t}\circle*{3}}
\put(42,1){\line(1,0){20}}
\put(62,1){\tikzmark{zg}\circle*{3}}
\put(62,1){\line(1,0){20}}
\put(82,1){\tikzmark{za}\circle*{3}}

\put(87,-1.5){\mbox{$\cdots$}}

\put(104,1){\tikzmark{zb}\circle*{3}}
\put(104,1){\line(1,0){20}}
\put(124,1){\tikzmark{zh}\circle*{3}}
\put(124,1){\line(1,0){20}}
\put(144,1){\circle*{3}}

\put(149,-1.5){\mbox{$\cdots$}}
\put(165,-1.5){\mbox{$\cdots$}}

\put(183,1){\circle*{3}}
\put(183,1){\line(1,0){20}}
\put(203,1){\circle*{3}}
\put(203,1){\line(1,0){20}}
\put(223,1){\tikzmark{zc}\circle*{3}}

\put(228,-1.5){\mbox{$\cdots$}}

\put(245,1){\tikzmark{zd}\circle*{3}}
\put(245,1){\line(1,0){20}}
\put(265,1){\circle*{3}}
\put(265,1){\line(1,0){20}}
\put(285,1){\tikzmark{ze}\circle*{3}}

\put(290,-1.5){\mbox{$\cdots$}}

\put(307,1){\circle*{3}}
\put(307,1){\line(1,0){20}}
\put(327,1){\tikzmark{zf}\circle*{3}}

\put(62,1){\circle{7}}
\put(124,1){\circle{7}}
\put(203,1){\circle{7}}
\put(265,1){\circle{7}}



  \end{picture}

 \begin{tikzpicture}[remember picture, overlay]
\draw [decorate,decoration={brace,amplitude=5pt,mirror},xshift=0.4pt,yshift=-0.4pt]({pic cs:z})+(-0.1pt,-3pt) coordinate (c) -- (c -| {pic cs:t}) node[black,midway,yshift=-0.4cm] {\footnotesize $y-1$};


\draw [decorate,decoration={brace,amplitude=5pt,mirror},xshift=0.4pt,yshift=-0.4pt]({pic cs:za})+(-0.1pt,-3pt) coordinate (c) -- (c -| {pic cs:zb}) node[black,midway,yshift=-0.4cm] {\footnotesize $z-1$};


\draw [decorate,decoration={brace,amplitude=5pt,mirror},xshift=0.4pt,yshift=-0.4pt]({pic cs:zc})+(-0.1pt,-3pt) coordinate (c) -- (c -| {pic cs:zd}) node[black,midway,yshift=-0.4cm] {\footnotesize $t-1$};

\draw [decorate,decoration={brace,amplitude=5pt,mirror},xshift=0.4pt,yshift=-0.4pt]({pic cs:ze})+(-0.1pt,-3pt) coordinate (c) -- (c -| {pic cs:zf}) node[black,midway,yshift=-0.4cm] {\footnotesize $x-1$};


\end{tikzpicture}
\end{tabular}}}

\end{document}

在此处输入图片描述

答案2

首先,您应该给出一个正确的边界框:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgf} 
\usetikzlibrary{tikzmark}
\usetikzlibrary{positioning}
\usetikzlibrary{patterns,arrows,decorations.pathreplacing}
\begin{document}

test test test test test test test test test test test test test test test test test test 
test test test test test test test test test test test test test test test test test test 
test test test test test test test test test test test test
\[
A_n\quad
\setlength{\unitlength}{0.9\unitlength}
\rule[-20\unitlength]{0pt}{0pt}
\begin{picture}(330,0)% <----------------- the bounding box

\put(0,1){\tikzmark{z}\circle*{3}}
\put(0,1){\line(1,0){20}}
\put(20,1){\circle*{3}}

\put(25,-1.5){\mbox{$\cdots$}}

\put(42,1){\tikzmark{t}\circle*{3}}
\put(42,1){\line(1,0){20}}
\put(62,1){\tikzmark{zg}\circle*{3}}
\put(62,1){\line(1,0){20}}
\put(82,1){\tikzmark{za}\circle*{3}}

\put(87,-1.5){\mbox{$\cdots$}}

\put(104,1){\tikzmark{zb}\circle*{3}}
\put(104,1){\line(1,0){20}}
\put(124,1){\tikzmark{zh}\circle*{3}}
\put(124,1){\line(1,0){20}}
\put(144,1){\circle*{3}}

\put(149,-1.5){\mbox{$\cdots$}}
\put(165,-1.5){\mbox{$\cdots$}}

\put(183,1){\circle*{3}}
\put(183,1){\line(1,0){20}}
\put(203,1){\circle*{3}}
\put(203,1){\line(1,0){20}}
\put(223,1){\tikzmark{zc}\circle*{3}}

\put(228,-1.5){\mbox{$\cdots$}}

\put(245,1){\tikzmark{zd}\circle*{3}}
\put(245,1){\line(1,0){20}}
\put(265,1){\circle*{3}}
\put(265,1){\line(1,0){20}}
\put(285,1){\tikzmark{ze}\circle*{3}}

\put(290,-1.5){\mbox{$\cdots$}}

\put(307,1){\circle*{3}}
\put(307,1){\line(1,0){20}}
\put(327,1){\tikzmark{zf}\circle*{3}}

\put(62,1){\circle{7}}
\put(124,1){\circle{7}}
\put(203,1){\circle{7}}
\put(265,1){\circle{7}}
\end{picture}
\begin{tikzpicture}[remember picture, overlay]
\draw [decorate,decoration={brace,amplitude=5pt,mirror},xshift=0.4pt,yshift=-0.4pt]({pic cs:z})+(-0.1pt,-3pt) coordinate (c) -- (c -| {pic cs:t}) node[black,midway,yshift=-0.4cm] {\footnotesize $y-1$};
\draw [decorate,decoration={brace,amplitude=5pt,mirror},xshift=0.4pt,yshift=-0.4pt]({pic cs:za})+(-0.1pt,-3pt) coordinate (c) -- (c -| {pic cs:zb}) node[black,midway,yshift=-0.4cm] {\footnotesize $z-1$};
\draw [decorate,decoration={brace,amplitude=5pt,mirror},xshift=0.4pt,yshift=-0.4pt]({pic cs:zc})+(-0.1pt,-3pt) coordinate (c) -- (c -| {pic cs:zd}) node[black,midway,yshift=-0.4cm] {\footnotesize $t-1$};
\draw [decorate,decoration={brace,amplitude=5pt,mirror},xshift=0.4pt,yshift=-0.4pt]({pic cs:ze})+(-0.1pt,-3pt) coordinate (c) -- (c -| {pic cs:zf}) node[black,midway,yshift=-0.4cm] {\footnotesize $x-1$};
\end{tikzpicture}
\]
test test test test test test test test test test test test test test test test test test 
test test test test test test test test test test test test test test test test test test 
test test test test test test test test test test test test

\end{document}

不需要tabular。但是也需要制定考虑深度的规则,否则图表下方的文本会与图表重叠。

为了稍微压缩图表,我将其减少\unitlength到默认值的 90%。

在此处输入图片描述

答案3

你可以使用这个dynkin-diagrams包。你的图表不会太大,但是你可以根据需要更改边长。

Dynkin 图中括号的示例

\documentclass{amsart}
\usepackage{dynkin-diagrams}
\newcommand\circleRoot[1]{\draw (root #1) circle (3pt);}
\begin{document}
\begin{center}
\begin{dynkinDiagram}{A}{**.***.***.***.***.**}
\circleRoot{4}\circleRoot{7}\circleRoot{10}\circleRoot{13}
\dynkinBrace[y-1]{1}{3}
\dynkinBrace[z-1]{5}{6}
\dynkinBrace[t-1]{11}{12}
\dynkinBrace[x-1]{14}{16}
\end{dynkinDiagram}
\end{center}
\end{document}

相关内容