3

I would like to shift my graph a couple of cm to the left, as it overflows a bit on the right. I tried enclosing the \graph in scope, like so:

\begin{scope}[shift={(-10,0)}]
\graph[...]{...};
\end{scope}

The output looks the same. Here is a runnable example.

Edit: I tried the proposed solution using \hspace{-1cm} on the example I provided and it worked. It did not work on the actual thing. I suspect the reason for that being the picture overflowing on the right. I updated the toy example below to make the graph overflow the page on the right.

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usetikzlibrary{positioning}
\usetikzlibrary{graphs}
\usetikzlibrary{shapes.arrows}

\title{Title} \subtitle{Subtitle}

\date{2023}

\usetikzlibrary{arrows.meta, svg.path, fit, positioning, matrix} \tikzset{% >={Latex[width=2mm,length=2mm]}, % Specifications for style of nodes: base/.style = {rectangle, rounded corners=0.5mm, draw=black, minimum width=10mm, minimum height=4mm, text centered}, process/.style = {base}, outerbox/.style={rectangle, draw=black, dashed} task/.style = {base, circle} }

\begin{document}

\begin{frame} \frametitle{}

\framesubtitle{} \hspace{-1cm} \begin{tikzpicture} [>=stealth, black!50, text=black, very thin, every new ->/.style = {shorten >=1pt}, graphs/every graph/.style = {edges=rounded corners}, hv path/.style = {to path={-| (\tikztotarget)}}, vh path/.style = {to path={|- (\tikztotarget)}}, t/.style = {circle, minimum size=1mm, thin, draw=black!70, scale=0.1, fill=black!70}, tl/.style = {circle, minimum size=1mm, thin, draw=blue!60, scale=0.1, fill=blue!60} ] \begin{scope}[shift={(10,10)}] \graph [grow left sep=.7mm, branch down=.3mm, simple] { 0 / ""[t] -- 1 / ""[t] -- 2 / ""[t] -- 3 / ""[t] -- 4 / ""[t] -- 5 / ""[t] -- 6 / ""[t] -- 7 / ""[t] -- 8 / ""[t] -- 9 / ""[t] -- 10 / ""[t] -- 11 / ""[t] -- 12 / ""[t] -- 13 / ""[t] -- 14 / ""[t] -- 15 / ""[t] -- 16 / ""[t] -- 17 / ""[t] -- 18 / ""[t] -- 19 / ""[t] -- 20 / ""[t] -- 21 / ""[t] -- 22 / ""[t] -- 23 / ""[t] -- 24 / ""[t] -- 25 / ""[t] -- 26 / ""[t] -- 27 / ""[t] -- 28 / ""[t] -- 29 / ""[t] -- 30 / ""[t] -- 31 / ""[t] -- 32 / ""[t] -- 33 / ""[t] -- 34 / ""[t] -- 35 / ""[t] -- 36 / ""[t] -- 37 / ""[t] -- 38 / ""[t] -- 39 / ""[t] -- 40 / ""[t] -- 41 / ""[t] -- 42 / ""[t] -- 43 / ""[t] -- 44 / ""[t] -- 45 / ""[t] -- 46 / ""[t] -- 47 / ""[t] -- 48 / ""[t] -- 49 / ""[t] -- 50 / ""[t] -- 51 / ""[t] -- 52 / ""[t] -- 53 / ""[t] -- 54 / ""[t] -- 55 / ""[t] -- 56 / ""[t] -- 57 / ""[t] -- 58 / ""[t] -- 59 / ""[t] -- 60 / ""[t] -- 61 / ""[t] -- 62 / ""[t] -- 63 / ""[t] -- 64 / ""[t] -- 65 / ""[t] -- 66 / ""[t] -- 67 / ""[t] -- 68 / ""[t] -- 69 / ""[t] -- 70 / ""[t] -- 71 / ""[t] -- 72 / ""[t] -- 73 / ""[t] -- 74 / ""[t] -- 75 / ""[t] -- 76 / ""[t] -- 77 / ""[t] -- 78 / ""[t] -- 79 / ""[t] -- 80 / ""[t] -- 81 / ""[t] -- 82 / ""[t] -- 83 / ""[t] -- 84 / ""[t] -- 85 / ""[t] -- 86 / ""[t] -- 87 / ""[t] -- 88 / ""[t] -- 89 / ""[t] -- 90 / ""[t] -- 91 / ""[t] -- 92 / ""[t] -- 93 / ""[t] -- 94 / ""[t] -- 95 / ""[t] -- 96 / ""[t] -- 97 / ""[t] -- 98 / ""[t] -- 99 / ""[t] -- 100 / ""[t] -- 101 / ""[t] -- 102 / ""[t] -- 103 / ""[t] -- 104 / ""[t] -- 105 / ""[t] -- 106 / ""[t] -- 107 / ""[t] -- 108 / ""[t] -- 109 / ""[t] -- t110 / ""[t];

};

\end{scope} \end{tikzpicture} \end{frame}

\end{document}

projetmbc
  • 13,315
  • 1
    What's the purpose of the shift? (Centering the image on the page; synchronize with surrounding text; synchronize with another image, ...) – Heiko Oberdiek Sep 04 '23 at 21:02
  • Sorry if that was not clear. It is to use a little bit of white space on the left in order to fit the picture on the page. Otherwise it overflows (shows truncated) on the right. – user443854 Sep 04 '23 at 21:13
  • 1
    So yeah, if I could center the image on the page, this would do it. – user443854 Sep 04 '23 at 21:14

2 Answers2

4

You could temporarily disable the margins by using columns:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usetikzlibrary{positioning}
\usetikzlibrary{graphs}
\usetikzlibrary{shapes.arrows}

\title{Title} \subtitle{Subtitle}

\date{2023}

\usetikzlibrary{arrows.meta, svg.path, fit, positioning, matrix} \tikzset{% >={Latex[width=2mm,length=2mm]}, % Specifications for style of nodes: base/.style = {rectangle, rounded corners=0.5mm, draw=black, minimum width=10mm, minimum height=4mm, text centered}, process/.style = {base}, outerbox/.style={rectangle, draw=black, dashed} task/.style = {base, circle} }

\begin{document}

\begin{frame} \frametitle{}

\framesubtitle{}

\begin{columns} \begin{column}{\paperwidth} \centering \begin{tikzpicture} [>=stealth, black!50, text=black, very thin, every new ->/.style = {shorten >=1pt}, graphs/every graph/.style = {edges=rounded corners}, hv path/.style = {to path={-| (\tikztotarget)}}, vh path/.style = {to path={|- (\tikztotarget)}}, t/.style = {circle, minimum size=1mm, thin, draw=black!70, scale=0.1, fill=black!70}, tl/.style = {circle, minimum size=1mm, thin, draw=blue!60, scale=0.1, fill=blue!60} ] \begin{scope}[shift={(10,10)}] \graph [grow left sep=.7mm, branch down=.3mm, simple] { 0 / ""[t] -- 1 / ""[t] -- 2 / ""[t] -- 3 / ""[t] -- 4 / ""[t] -- 5 / ""[t] -- 6 / ""[t] -- 7 / ""[t] -- 8 / ""[t] -- 9 / ""[t] -- 10 / ""[t] -- 11 / ""[t] -- 12 / ""[t] -- 13 / ""[t] -- 14 / ""[t] -- 15 / ""[t] -- 16 / ""[t] -- 17 / ""[t] -- 18 / ""[t] -- 19 / ""[t] -- 20 / ""[t] -- 21 / ""[t] -- 22 / ""[t] -- 23 / ""[t] -- 24 / ""[t] -- 25 / ""[t] -- 26 / ""[t] -- 27 / ""[t] -- 28 / ""[t] -- 29 / ""[t] -- 30 / ""[t] -- 31 / ""[t] -- 32 / ""[t] -- 33 / ""[t] -- 34 / ""[t] -- 35 / ""[t] -- 36 / ""[t] -- 37 / ""[t] -- 38 / ""[t] -- 39 / ""[t] -- 40 / ""[t] -- 41 / ""[t] -- 42 / ""[t] -- 43 / ""[t] -- 44 / ""[t] -- 45 / ""[t] -- 46 / ""[t] -- 47 / ""[t] -- 48 / ""[t] -- 49 / ""[t] -- 50 / ""[t] -- 51 / ""[t] -- 52 / ""[t] -- 53 / ""[t] -- 54 / ""[t] -- 55 / ""[t] -- 56 / ""[t] -- 57 / ""[t] -- 58 / ""[t] -- 59 / ""[t] -- 60 / ""[t] -- 61 / ""[t] -- 62 / ""[t] -- 63 / ""[t] -- 64 / ""[t] -- 65 / ""[t] -- 66 / ""[t] -- 67 / ""[t] -- 68 / ""[t] -- 69 / ""[t] -- 70 / ""[t] -- 71 / ""[t] -- 72 / ""[t] -- 73 / ""[t] -- 74 / ""[t] -- 75 / ""[t] -- 76 / ""[t] -- 77 / ""[t] -- 78 / ""[t] -- 79 / ""[t] -- 80 / ""[t] -- 81 / ""[t] -- 82 / ""[t] -- 83 / ""[t] -- 84 / ""[t] -- 85 / ""[t] -- 86 / ""[t] -- 87 / ""[t] -- 88 / ""[t] -- 89 / ""[t] -- 90 / ""[t] -- 91 / ""[t] -- 92 / ""[t] -- 93 / ""[t] -- 94 / ""[t] -- 95 / ""[t] -- 96 / ""[t] -- 97 / ""[t] -- 98 / ""[t] -- 99 / ""[t] -- 100 / ""[t] -- 101 / ""[t] -- 102 / ""[t] -- 103 / ""[t] -- 104 / ""[t] -- 105 / ""[t] -- 106 / ""[t] -- 107 / ""[t] -- 108 / ""[t] -- 109 / ""[t] -- t110 / ""[t];

};

\end{scope} \end{tikzpicture} \end{column} \end{columns} \end{frame}

\end{document}

enter image description here

1

Your graph is wider that \textwidth, consequently it protrude right border of frames text area. This problem you can solve on two ways:

  • make graph narrower, for example reducing distances between nodes in graphs (which are already small)
  • locally enlarge width of text area in frame.

For the second possibility you can use adjustwidth of changepage package:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{%arrows.meta, 
                %backgrounds,
                graphs,
                %fit,
                %matrix, 
                %positioning,
                %shapes.arrows, svg.path
                }
\usepackage{changepage}

\title{Title} \subtitle{Subtitle}

\date{2023}

\begin{document} \begin{frame}

\begin{adjustwidth}{-9mm}{-9mm} \centering \begin{tikzpicture}[ %>=stealth, black!50, text=black, very thin, %every new ->/.style = {shorten >=1pt}, %graphs/every graph/.style = {edges=rounded corners}, %hv path/.style = {to path={-| (\tikztotarget)}}, %vh path/.style = {to path={|- (\tikztotarget)}}, t/.style = {circle, minimum size=1mm, scale=0.1, thin, draw=black!70, fill=black!70}, %tl/.style = {t, draw=blue!60, fill=blue!60} ] \graph [grow left sep=.7mm, branch down=.3mm, simple] { 0 / ""[t] -- 1 / ""[t] -- 2 / ""[t] -- 3 / ""[t] -- 4 / ""[t] -- 5 / ""[t] -- 6 / ""[t] -- 7 / ""[t] -- 8 / ""[t] -- 9 / ""[t] -- 10 / ""[t] -- 11 / ""[t] -- 12 / ""[t] -- 13 / ""[t] -- 14 / ""[t] -- 15 / ""[t] -- 16 / ""[t] -- 17 / ""[t] -- 18 / ""[t] -- 19 / ""[t] -- 20 / ""[t] -- 21 / ""[t] -- 22 / ""[t] -- 23 / ""[t] -- 24 / ""[t] -- 25 / ""[t] -- 26 / ""[t] -- 27 / ""[t] -- 28 / ""[t] -- 29 / ""[t] -- 30 / ""[t] -- 31 / ""[t] -- 32 / ""[t] -- 33 / ""[t] -- 34 / ""[t] -- 35 / ""[t] -- 36 / ""[t] -- 37 / ""[t] -- 38 / ""[t] -- 39 / ""[t] -- 40 / ""[t] -- 41 / ""[t] -- 42 / ""[t] -- 43 / ""[t] -- 44 / ""[t] -- 45 / ""[t] -- 46 / ""[t] -- 47 / ""[t] -- 48 / ""[t] -- 49 / ""[t] -- 50 / ""[t] -- 51 / ""[t] -- 52 / ""[t] -- 53 / ""[t] -- 54 / ""[t] -- 55 / ""[t] -- 56 / ""[t] -- 57 / ""[t] -- 58 / ""[t] -- 59 / ""[t] -- 60 / ""[t] -- 61 / ""[t] -- 62 / ""[t] -- 63 / ""[t] -- 64 / ""[t] -- 65 / ""[t] -- 66 / ""[t] -- 67 / ""[t] -- 68 / ""[t] -- 69 / ""[t] -- 70 / ""[t] -- 71 / ""[t] -- 72 / ""[t] -- 73 / ""[t] -- 74 / ""[t] -- 75 / ""[t] -- 76 / ""[t] -- 77 / ""[t] -- 78 / ""[t] -- 79 / ""[t] -- 80 / ""[t] -- 81 / ""[t] -- 82 / ""[t] -- 83 / ""[t] -- 84 / ""[t] -- 85 / ""[t] -- 86 / ""[t] -- 87 / ""[t] -- 88 / ""[t] -- 89 / ""[t] -- 90 / ""[t] -- 91 / ""[t] -- 92 / ""[t] -- 93 / ""[t] -- 94 / ""[t] -- 95 / ""[t] -- 96 / ""[t] -- 97 / ""[t] -- 98 / ""[t] -- 99 / ""[t] -- 100 / ""[t] -- 101 / ""[t] -- 102 / ""[t] -- 103 / ""[t] -- 104 / ""[t] -- 105 / ""[t] -- 106 / ""[t] -- 107 / ""[t] -- 108 / ""[t] -- 109 / ""[t] -- t110 / ""[t]; }; \end{tikzpicture} \end{adjustwidth}

\end{frame} \end{document}

Off-topic:

  • it is sufficient to load each libraries just one times
  • for this particular example only graphs library is needed
  • your graph use only t style definition

so all aforementioned cases in the above MWE are comments off.

enter image description here

and details of first three nodes:

enter image description here

Zarko
  • 296,517