2

could you please help me to minimize the gap between two pictures to make them placed side by side and also how to scale them because they look smaller unfortunately. I got tired playing with their coordinates and width to scale it but with no luck. Here is my attempt

\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}
0

o boy, how complex code for simple graphs ...

see, if the following MWE gives result close to what you like to have:

\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}

enter image description here

red lines on image indicate text area. as can be seen, image has normal size font, both graphs are placed in one row (but the text width is increased with use of added geometry package). also all coordinates are rounded to max. 2 digits (more digits is useless ...), for image options is defined tikzset "graph-1" (you can choose different name for it).

use of \resizebox for TikZ images is not recommend. if you like to change image size, rather use scale option or change basic unit as it is done in above MWE (with x=0.8cm and y=0.8cm).

  • Thanks a lot for your help and support. sorry I'm still beginner using Tikz. always learning! – Mal JA Jun 9 '17 at 18:22
  • @MalJA, instead of saying thanks you can upvote my answer. From comparison between your MWE, accepted answer and my answer, you can learn a lot. However, if you prefer complicated and unclear code, is up to you :) – Zarko Jun 9 '17 at 18:34
1

The \resizebox should be no greater than the text width. Also, the generated code needs some cleaning; I moved color declarations above the figure and used a single command \scriptsize. Finally, figure positioning like [!h] should be the last thing to do at a finalized document when no other solution is possible (these cases are very rare).

\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}

enter image description here

  • Thanks a lot! would you mind please to explain more what you mean by "The \resizebox should be no greater than the text width"? sorry I'm still beginner using Tikz. Thanks a lot – Mal JA Jun 9 '17 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.