制作两张彼此相邻的 tikz 图片

制作两张彼此相邻的 tikz 图片

你能帮我缩小两张图片之间的间隙,让它们并排放置吗?还有,如何缩放它们,因为它们看起来比较小,这很不幸。我厌倦了摆弄它们的坐标和宽度来缩放,但没有成功。这是我的尝试

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}
\vskip -1.1 in
\begin{figure}[!h]
\centering
 \hspace*{-1em}\resizebox {1.7\textwidth} {!} {
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-3,-7.122926829268283) rectangle (19.680487804878055,6.203902439024388);
\draw (0.,1.38)-- (5.,1.38);
\draw (0.,-1.38)-- (5.,-1.38);
\draw (-0.17,1.85) node[anchor=north west] {$\scriptstyle 1$};
\draw (2.860975609756099,1.85) node[anchor=north west] {$\scriptstyle r$};
\draw (4.831707317073173,1.85) node[anchor=north west] {$\scriptstyle n$};
\draw (0.9878048780487814,1.85) node[anchor=north west] {$\scriptstyle\dots\ \ X \ \ \dots$};
\draw (-0.12439024390243851,-1.4) node[anchor=north west] {$\scriptstyle1$};
\draw (4.812195121951222,-1.4) node[anchor=north west] {$\scriptstyle n$};
\draw (1.9243902439024403,-1.4) node[anchor=north west] {$\scriptstyle\dots\ Yb \ \dots$};
\draw (0.4,-1.4) node[anchor=north west] {$\scriptstyle i_{1}b$};
\draw (3.5,-1.4) node[anchor=north west] {$\scriptstyle i_{r}b$};
\draw (-0.9048780487804876,0.3) node[anchor=north west] {$a_{_{Yb}}$};
\draw (0.5,1.85) node[anchor=north west] {$\scriptstyle 2$};
\draw (1.2,-1.4) node[anchor=north west] {$\scriptstyle i_{2}b$};
\draw (0.,1.38)-- (0.7536585365853666,-1.38);
\draw (0.695121951219513,1.38)-- (1.4951219512195133,-1.38);
\draw (2.997560975609758,1.38)-- (3.758536585365856,-1.38);
\begin{scriptsize}
\draw [fill=xdxdff] (0.,1.38) circle (1.0pt);
\draw [fill=xdxdff] (2.997560975609758,1.38) circle (1.0pt);
\draw [fill=xdxdff] (5.,1.38) circle (1.0pt);
\draw [fill=xdxdff] (0.,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (5.,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (3.758536585365856,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (0.7536585365853666,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (0.695121951219513,1.38) circle (1.0pt);
\draw [fill=xdxdff] (1.4951219512195133,-1.38) circle (1.0pt);
\end{scriptsize}
\end{tikzpicture}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}
 \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-3,-7.122926829268286) rectangle (19.680487804878055,6.203902439024386);
\draw (0.,1.38)-- (5.,1.38);
\draw (0.,0.)-- (5.,0.);
\draw (0.,-1.38)-- (5.,-1.38);
\draw (-0.10487804878048729,1.9) node[anchor=north west] {$\scriptstyle 1$};
\draw (2.860975609756099,1.9) node[anchor=north west] {$\scriptstyle r$};
\draw (4.831707317073173,1.9) node[anchor=north west] {$\scriptstyle n$};
\draw (-0.10487804878048729,-0.04) node[anchor=north west] {$\scriptstyle1$};
\draw (0.6170731707317081,-0.01) node[anchor=north west] {$\scriptstyle i_{1}$};
\draw (0.9,1.9) node[anchor=north west] {$\scriptstyle\dots\ \ X \ \ \dots$};
\draw (2.2,-0.01) node[anchor=north west] {$\scriptstyle\dots\ Y\ \dots$};
\draw (4.0707317073170755,-0.01) node[anchor=north west] {$\scriptstyle i_{r}$};
\draw (4.909756097560978,-0.04) node[anchor=north west] {$\scriptstyle n$};
\draw (-0.12439024390243851,-1.4) node[anchor=north west] {$\scriptstyle1$};
\draw (4.812195121951222,-1.4) node[anchor=north west] {$\scriptstyle n$};
\draw (0.,1.38)-- (1.,0.);
\draw (3.,1.38)-- (4.,0.);
\draw (4.,0.)-- (3.524390243902441,-1.38);
\draw (0.9878048780487814,-1.4) node[anchor=north west] {$\scriptstyle\dots\ Yb \ \dots$};
\draw (0.2853658536585372,-1.4) node[anchor=north west] {$\scriptstyle i_{2}b$};
\draw (3.4073170731707334,-1.4) node[anchor=north west] {$\scriptstyle i_{r}b$};
\draw (-0.9048780487804876,1.130731707317073) node[anchor=north west] {$a_{_{Y}}$};
\draw (-0.8268292682926827,-0.19609756097560868) node[anchor=north west] {$b$};
\draw (0.3243902439024397,1.9) node[anchor=north west] {$\scriptstyle2$};
\draw (0.5,1.38)-- (1.475609756097562,0.);
\draw (1.475609756097562,0.)-- (0.38292682926829336,-1.38);
\draw (1.,0.)-- (2.782926829268294,-1.38);
\draw (1.5926829268292695,-0.01) node[anchor=north west] {$\scriptstyle i_{2}$};
\draw (2.6463414634146356,-1.4) node[anchor=north west] {$\scriptstyle i_{1}b$};
\begin{scriptsize}
\draw [fill=xdxdff] (0.,1.38) circle (1.0pt);
\draw [fill=xdxdff] (3.,1.38) circle (1.0pt);
\draw [fill=xdxdff] (5.,1.38) circle (1.0pt);
\draw [fill=uuuuuu] (0.,0.) circle (1.0pt);
\draw [fill=xdxdff] (1.,0.) circle (1.0pt);
\draw [fill=xdxdff] (4.,0.) circle (1.0pt);
\draw [fill=xdxdff] (5.,0.) circle (1.0pt);
\draw [fill=xdxdff] (0.,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (5.,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (3.524390243902441,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (0.38292682926829336,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (0.5,1.38) circle (1.0pt);
\draw [fill=xdxdff] (1.475609756097562,0.) circle (1.0pt);
\draw [fill=xdxdff] (2.782926829268294,-1.38) circle (1.0pt);
\end{scriptsize}
\end{tikzpicture}
}
%\captionsetup{font=scriptsize}
 %\vspace{-2.5 em}
%\caption{$vg$ corresponds to the reflection $g^{-1}s_{v}g$.}
\vskip -1.5 in
\end{figure}
\end{document}

答案1

哦,天哪,简单的图形的代码有多复杂......

看看以下 MWE 是否给出接近您想要的结果:

\documentclass[10pt]{article}
\usepackage{geometry}% <-- added, 
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{mathrsfs}

\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}

\tikzset{graph-1/.style = {
  line cap = round,
 line join = round,
         > = triangle 45,
 x=0.8cm, y=0.8cm,
 every node/.append style = {inner ysep=2mm}
                            }
        }% end of tikzset
\begin{document}
\pagestyle{empty}

    \begin{figure}[ht]
    \centering
\begin{tikzpicture}[graph-1]
\draw (0, 1.5) -- + (7,0);
\draw (0,-1.5) -- + (7,0);
%%%
\foreach \x in {0, 1, 4}
\draw  (\x,1.5) -- (\x+1,-1.5);
%
\foreach \x/\label in {0/1, 1/2, 4/r, 7/n}
\draw[fill=xdxdff]  (\x,1.5) circle (2pt) node[above] {$\label$};
%
\foreach \x/\label in {0/1, 1/i_{1}b, 2/i_{2}b, 5/i_{r}b,7/n}
\draw[fill=xdxdff]  (\x,-1.5) circle (2pt) node[below] {$\label$};
%
\node[left] at (0,0) {$a_{Yb}$};
%
\node[above] at (2.5, 1.5) {$\dots\ X\ \dots$};
\node[below] at (3.5,-1.5) {$\dots\ Yb\ \dots$};
\end{tikzpicture}
\hfil
 \begin{tikzpicture}[graph-1]
\draw (0, 1.5) -- + (7,0);
\draw (0, 0.0) -- + (7,0);
\draw (0,-1.5) -- + (7,0);
%%%
\foreach \x in {0, 1, 4}
\draw  (\x,1.5) -- (\x+2,-0.0);
\draw  (2,0) -- (4,-1.5);
\draw  (3,0) -- (1,-1.5);
\draw  (6,0) -- (5,-1.5);
%
\foreach \x/\label in {0/1, 1/2, 4/r, 7/n}
\draw[fill=xdxdff]  (\x,1.5) circle (2pt) node[above] {$\label$};
%
\draw[fill=uuuuuu]  (0,0) circle (2pt) node[below] {$1$};
\draw[fill=xdxdff]  (2,0) circle (2pt) node[below left] {$i_{1}b$}
                    (3,0) circle (2pt) node[below right] {$i_{2}b$}
                    (6,0) circle (2pt) node[below right] {$i_{r}b$}
                    (7,0) circle (2pt) node[below] {$n$};
%
\foreach \x/\label in {0/1, 1/i_{2}b, 4/i_{1}b, 5/i_{r}b,7/n}
\draw[fill=xdxdff]  (\x,-1.5) circle (2pt) node[below] {$\label$};
%
\node[left]     at (0, 0.75) {$a_Y$};
\node[left=2mm] at (0,-0.75) {$b$};
%
\node[above] at (2.5, 1.5) {$\dots\ X\ \dots$};
\node[below] at (4.5, 0.0) {$\dots\ Y\ \dots$};
\node[below] at (2.5,-1.5) {$\dots\ Yb\ \dots$};
\end{tikzpicture}
%
\caption{$vg$ corresponds to the reflection $g^{-1}s_{v}g$.}
    \end{figure}
\end{document}

在此处输入图片描述

图像上的红线表示文本区域。可以看出,图像具有正常大小的字体,两个图形都放在一行中(但使用添加的geometry包增加了文本宽度)。所有坐标都四舍五入为最大 2 位数字(更多的数字是没用的......),对于图像选项定义为tikzset“graph-1”(您可以为其选择不同的名称)。

\resizebox不建议对 TikZ 图像使用。如果您想更改图像大小,请使用scale选项或更改基本单位,就像上面的 MWE 中所做的那样(使用x=0.8cmy=0.8cm)。

答案2

不应\resizebox大于文本宽度。此外,生成的代码需要一些清理;我将颜色声明移到图形上方并使用单个命令\scriptsize。最后,[!h]在没有其他解决方案的情况下,图形定位应该是最终文档中最后要做的事情(这些情况非常罕见)。

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}

\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}

\begin{figure}
\centering
\resizebox{1\textwidth}{!}{\scriptsize
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw (0.,1.38)-- (5.,1.38);
\draw (0.,-1.38)-- (5.,-1.38);
\draw (-0.17,1.85) node[anchor=north west] {$\scriptstyle 1$};
\draw (2.860975609756099,1.85) node[anchor=north west] {$\scriptstyle r$};
\draw (4.831707317073173,1.85) node[anchor=north west] {$\scriptstyle n$};
\draw (0.9878048780487814,1.85) node[anchor=north west] {$\scriptstyle\dots\ \ X \ \ \dots$};
\draw (-0.12439024390243851,-1.4) node[anchor=north west] {$\scriptstyle1$};
\draw (4.812195121951222,-1.4) node[anchor=north west] {$\scriptstyle n$};
\draw (1.9243902439024403,-1.4) node[anchor=north west] {$\scriptstyle\dots\ Yb \ \dots$};
\draw (0.4,-1.4) node[anchor=north west] {$\scriptstyle i_{1}b$};
\draw (3.5,-1.4) node[anchor=north west] {$\scriptstyle i_{r}b$};
\draw (-0.9048780487804876,0.3) node[anchor=north west] {$a_{Yb}$};
\draw (0.5,1.85) node[anchor=north west] {$\scriptstyle 2$};
\draw (1.2,-1.4) node[anchor=north west] {$\scriptstyle i_{2}b$};
\draw (0.,1.38)-- (0.7536585365853666,-1.38);
\draw (0.695121951219513,1.38)-- (1.4951219512195133,-1.38);
\draw (2.997560975609758,1.38)-- (3.758536585365856,-1.38);
\draw [fill=xdxdff] (0.,1.38) circle (1.0pt);
\draw [fill=xdxdff] (2.997560975609758,1.38) circle (1.0pt);
\draw [fill=xdxdff] (5.,1.38) circle (1.0pt);
\draw [fill=xdxdff] (0.,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (5.,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (3.758536585365856,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (0.7536585365853666,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (0.695121951219513,1.38) circle (1.0pt);
\draw [fill=xdxdff] (1.4951219512195133,-1.38) circle (1.0pt);
\end{tikzpicture}
\quad
 \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw (0.,1.38)-- (5.,1.38);
\draw (0.,0.)-- (5.,0.);
\draw (0.,-1.38)-- (5.,-1.38);
\draw (-0.10487804878048729,1.9) node[anchor=north west] {$\scriptstyle 1$};
\draw (2.860975609756099,1.9) node[anchor=north west] {$\scriptstyle r$};
\draw (4.831707317073173,1.9) node[anchor=north west] {$\scriptstyle n$};
\draw (-0.10487804878048729,-0.04) node[anchor=north west] {$\scriptstyle1$};
\draw (0.6170731707317081,-0.01) node[anchor=north west] {$\scriptstyle i_{1}$};
\draw (0.9,1.9) node[anchor=north west] {$\scriptstyle\dots\ \ X \ \ \dots$};
\draw (2.2,-0.01) node[anchor=north west] {$\scriptstyle\dots\ Y\ \dots$};
\draw (4.0707317073170755,-0.01) node[anchor=north west] {$\scriptstyle i_{r}$};
\draw (4.909756097560978,-0.04) node[anchor=north west] {$\scriptstyle n$};
\draw (-0.12439024390243851,-1.4) node[anchor=north west] {$\scriptstyle1$};
\draw (4.812195121951222,-1.4) node[anchor=north west] {$\scriptstyle n$};
\draw (0.,1.38)-- (1.,0.);
\draw (3.,1.38)-- (4.,0.);
\draw (4.,0.)-- (3.524390243902441,-1.38);
\draw (0.9878048780487814,-1.4) node[anchor=north west] {$\scriptstyle\dots\ Yb \ \dots$};
\draw (0.2853658536585372,-1.4) node[anchor=north west] {$\scriptstyle i_{2}b$};
\draw (3.4073170731707334,-1.4) node[anchor=north west] {$\scriptstyle i_{r}b$};
\draw (-0.9048780487804876,1.130731707317073) node[anchor=north west] {$a_{_{Y}}$};
\draw (-0.8268292682926827,-0.19609756097560868) node[anchor=north west] {$b$};
\draw (0.3243902439024397,1.9) node[anchor=north west] {$\scriptstyle2$};
\draw (0.5,1.38)-- (1.475609756097562,0.);
\draw (1.475609756097562,0.)-- (0.38292682926829336,-1.38);
\draw (1.,0.)-- (2.782926829268294,-1.38);
\draw (1.5926829268292695,-0.01) node[anchor=north west] {$\scriptstyle i_{2}$};
\draw (2.6463414634146356,-1.4) node[anchor=north west] {$\scriptstyle i_{1}b$};
\draw [fill=xdxdff] (0.,1.38) circle (1.0pt);
\draw [fill=xdxdff] (3.,1.38) circle (1.0pt);
\draw [fill=xdxdff] (5.,1.38) circle (1.0pt);
\draw [fill=uuuuuu] (0.,0.) circle (1.0pt);
\draw [fill=xdxdff] (1.,0.) circle (1.0pt);
\draw [fill=xdxdff] (4.,0.) circle (1.0pt);
\draw [fill=xdxdff] (5.,0.) circle (1.0pt);
\draw [fill=xdxdff] (0.,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (5.,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (3.524390243902441,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (0.38292682926829336,-1.38) circle (1.0pt);
\draw [fill=xdxdff] (0.5,1.38) circle (1.0pt);
\draw [fill=xdxdff] (1.475609756097562,0.) circle (1.0pt);
\draw [fill=xdxdff] (2.782926829268294,-1.38) circle (1.0pt);
\end{tikzpicture}
}
%\captionsetup{font=scriptsize}
%\vspace{-2.5 em}
%\caption{$vg$ corresponds to the reflection $g^{-1}s_{v}g$.}
\end{figure}

\end{document}

在此处输入图片描述

相关内容