1

I need to make a 1D draw for a random walk. The problem is that beamer doesn't let me use the same code I used for "report". And I don't know what's wrong, It's exactly the same I used

It shows me this message:

Sorry, but "MiKTeX Compiler Driver" did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:\Users\Sergio1\AppData\Local\MiKTeX\miktex\log\texify.log

And the code I used:

\documentclass{beamer}
    
    \usepackage{tikz}
    \usetikzlibrary{babel}
    \usetikzlibrary{svg.path}
    
    
    \begin{document}
     \begin{frame}    
     \begin{tikzpicture}
         \draw (-6,0) -- (6,0) ; 
         \foreach \x/\y in  {-6/{$x-2h$},-3/{$x-h$},0/{$x$},3/{$x+h$},6/{$x+2h$}}              
         \draw[shift={(\x,0)},color=black] (0pt,3pt) -- (0pt,-3pt)node[below] {\y};
         \foreach \x/\y in {-6/-3,-3/0,0/3,3/6}
         \draw[bend left,looseness=1.4, shorten >=4pt,shorten <=4pt, blue, thick](\x,0)to node[ label=90: 1/2]{}(\y,0);
          \draw (-6,0) -- (6.5,0) node[right] {$h \mathbb{Z}$};
      \end{tikzpicture}
     \end{frame}
   \end{document}

EDIT: I checked the log and it shows this, no idea what it means

*2021-04-16 10:52:31,168+0200 INFO texify - this process (12816) started by 'miktex-texworks' with command line: "C:\Program Files\MiKTeX\miktex\bin\x64\texify.exe" --pdf --synctex=1 --clean TFG-diapositiva.tex

2021-04-16 10:52:31,213+0200 INFO texify.core - start process: pdflatex --synctex=1 "C:/Users/Sergio1/Desktop/Cosas de la Uni/TFG/Mi trabajo\TFG-diapositiva.tex"

2021-04-16 10:52:34,075+0200 FATAL texify.core - TeX engine failed for some reason (see log file). 2021-04-16 10:52:34,076+0200 FATAL texify.core - Data:

2021-04-16 10:52:34,076+0200 FATAL texify.core - Source: Programs\MiKTeX\texify\mcd.cpp:1528

2021-04-16 10:52:34,080+0200 FATAL texify - TeX engine failed for some reason (see log file).

2021-04-16 10:52:34,080+0200 FATAL texify - Info:

2021-04-16 10:52:34,080+0200 FATAL texify - Source: Programs\MiKTeX\texify\mcd.cpp

2021-04-16 10:52:34,080+0200 FATAL texify - Line: 1528

2021-04-16 10:52:34,082+0200 ERROR texify - minor issue: It has been a long time since a MiKTeX administrator has checked for updates*

11
  • 1
    It is better to wrap the body of the \foreach loop in {...} such that it is clear what is part of the loop
    – daleif
    Apr 16, 2021 at 8:19
  • Your code is correct (here, it compiles very well). What errors do you see in the file C:\Users\Sergio1\AppData\Local\MiKTeX\miktex\log\texify.log? Apr 16, 2021 at 8:42
  • @Serch For me, your code is working... Do you have some other libraries etc. in your preamble?
    – Excelsior
    Apr 16, 2021 at 8:50
  • No @Excelsior, that's everything I have on my code. That's what bothers me. On \documentclass{report} it works perfectly
    – Serch
    Apr 16, 2021 at 8:51
  • @PaulGaborit. I updated the question with the log
    – Serch
    Apr 16, 2021 at 8:56

4 Answers 4

1

Your current code compiles fine for me on TeXLive 2021. But I would suggest rewriting the \foreach like this

\documentclass{beamer}
    
    \usepackage{tikz}
    \usetikzlibrary{babel}
    \usetikzlibrary{svg.path}
    
    
    \begin{document}
     \begin{frame}    
     \begin{tikzpicture}
         \draw (-6,0) -- (6,0) ; 
         \foreach \x/\y in  {-6/{$x-2h$},-3/{$x-h$},0/{$x$},3/{$x+h$},6/{$x+2h$}}{              
           \draw[shift={(\x,0)},color=black] (0pt,3pt) -- (0pt,-3pt)node[below] {\y};
         }
         \foreach \x/\y in {-6/-3,-3/0,0/3,3/6}{
           \draw[bend left,looseness=1.4, shorten >=4pt,shorten <=4pt, blue, thick](\x,0)to node[ label=90: 1/2]{}(\y,0);
         }
          \draw (-6,0) -- (6.5,0) node[right] {$h \mathbb{Z}$};
      \end{tikzpicture}
     \end{frame}
   \end{document}

Then it is much clearer when \x and \y are defined.

1

In one loop, using TikZ libraries arrows.meta and quotes:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
%                babel,     % not needed in this MWE
                quotes,
%                svg.path   % not needed in this MWE
                }


\begin{document}
\begin{frame}
    \begin{tikzpicture}
   \draw[-Straight Barb] 
        (-5,0) -- (5,0) node[right] {$h\in\mathbb{Z}$};
\foreach \i [count=\j from -2] in  {x-2h,x-h,x,x+h,x+2h}%
 {
 \draw  (2*\j,3pt) -- ++ (0,-6pt) node[below] {$\i$};
 \ifnum\j<2
 \draw [blue, thick, bend left=45, 
        shorten >=4pt,shorten <=4pt]
        (2*\j,0) to ["1/2"] ++ (2,0);
 \fi
 }
    \end{tikzpicture}
\end{frame}
\end{document}

enter image description here

0

Ok. I figured out how to do it. It's messy, but that's the only way I found out

I just used the code on the report document, took the page where the image is located, used photospot to get the png of the draw, and manually introduce it to the beamer with \includegraphics

0

In case the problem comes from the shift argument, you can try my approach:

enter image description here

\documentclass{beamer}

\usepackage{tikz}
%\usetikzlibrary{babel}
%\usetikzlibrary{svg.path}

\tikzset{%
    every node/.style={font=\strut}, % <- same size for all nodes
}

\begin{document}
    \begin{frame}    
        \begin{tikzpicture}[scale=0.75] % scaling to fit the frame
%           \draw (-6,0) -- (6,0); <- you define it again below  
            \foreach \x/\y in  {-6/{$x-2h$},-3/{$x-h$},0/{$x$},3/{$x+h$},6/{$x+2h$}}{%
                \draw[color=black]  (\x,3pt) -- (\x,-3pt) node[below] {\y};
            }
            
            \foreach \x/\y in {-6/-3,-3/0,0/3,3/6}{%
                \draw[bend left,looseness=1.4,shorten >=4pt,shorten <=4pt,blue,thick](\x,0) to node[above]{1/2}(\y,0);
            }
            
            \draw[-stealth] (-6,0) -- (7,0) node[right] {$h \mathbb{Z}$};
        \end{tikzpicture}
    \end{frame}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .