Order of \pause in beamer with tikz - tex

I reduced my problem to the following simple example:
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\frametitle{Example:}
\pause
\begin{tikzpicture}
\draw (0,0) rectangle (2,2);
\pause
\draw (1,1) circle [radius=1cm];
\end{tikzpicture}
\pause
Comment
\end{frame}
\end{document}
I would like to see the following behaviour:
Slide 1: Title "Example:"
Slide 2: previous contents and a rectangle
Slide 3: previous contents and a circle
Slide 4: previous contents and "Comment"
However I get:
Slide 1: Title "Example:"
Slide 2: previous contents, a rectangle and "Comment"
Slide 3: Title "Example:", a rectangle and a circle
Slide 4: previous contents and "Comment"
In other words, "Comment" appears in slide 2 (it should not) and in slide 4 (where it should). I know that there are issues with using \pause within tikzpicture environment and I tried other solutions like \only but it did not work. Finally I split my picture in two halves and used \vspace{-20.5mm} between them but that's a very poor solutions for a more complicated picture which would require very fine adjustments. Any other suggestions?

To choose the order of appearance of the pauses, you can use \onslide:
\begin{frame}
\frametitle{Example:}
\onslide<2->{
\begin{tikzpicture}
\draw (0,0) rectangle (2,2);
\onslide<3->{
\draw (1,1) circle [radius=1cm];
}
\end{tikzpicture}
}
\onslide<4->{
Comment
}
\end{frame}
See this example.

Related

Tikz node won't apply left (nor right) alignment

I have been struggling with this issue for a while. I want to insert a title on a white box on top of a background image for a report cover, and everything is coming up great with the exception of the title alignment. It is centered and I want to make it left aligned, but so far none of the options I have tried have worked.
So far, this is what I got:
\usepackage{tikz}
\usepackage{makecell}
\begin{titlepage}
\setlength{\parindent}{0pt}
\begin{figure}
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\includegraphics[scale=0.2]{example-image-10x16}};
\node[fill=white, scale=2, text=red, text width=94mm, align=left] at ([xshift=7mm,yshift=30mm]current page.center) {\makecell{\textbf{The title goes here and it is very}\\\textbf{long so it covers two lines}\\\Xhline{2\arrayrulewidth}\\[-18pt]\scalebox{.35}{\textbf{\fontfamily{phv}\selectfont DEPARTMENT OF SOME ENGINEERING DISCIPLINE $\vert$ MY UNIVERSITY}}\\[-7pt]\scalebox{.35}{\textbf{\fontfamily{phv}\selectfont MY NAME HERE $\vert$ NAME OF PROGRAM}}}};
\end{tikzpicture}
\end{figure}
\end{titlepage}
I have tried raggedright options with the \usepackage{ragged2e} and the \begin{flushleft}\end{flushleft} approach with different variations but I don't seem to make it align to the left or even to the right.
Cheers!
I would avoid all this messing with \makecell and whatnot. Instead use a simple minipage:
\documentclass{article}
\usepackage{tikz}
\usepackage{makecell}
\begin{document}
\begin{titlepage}
\setlength{\parindent}{0pt}
\begin{figure}
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\includegraphics[scale=0.2]{example-image-10x16}};
\node[
fill=white,
text=red,
text width=92mm,
font=\bfseries
] at ([yshift=30mm]current page.center) {
\begin{minipage}{\linewidth}
\LARGE The title goes here and it is very
long so it covers two lines
\vskip-0.5cm
\rule{\textwidth}{1pt}
\vskip0.1cm
\scriptsize\fontfamily{phv}\selectfont DEPARTMENT OF SOME ENGINEERING DISCIPLINE $\vert$ MY UNIVERSITY
NAME HERE $\vert$ NAME OF PROGRAM
\end{minipage}};
\end{tikzpicture}
\end{figure}
\end{titlepage}
\end{document}

Using an environment such as itemize in a tikz node shifts vertical alignment

If I use an environment in a tikz node, the vertical alignment is shifted. The following example shows the difference, in the first case, where no environment is used, everything is fine.
\begin{frame}
% alignment is correct without using itemize
\begin{tikzpicture}
\node[text width=\textwidth, text centered,fill=yellow, fill opacity=0.4,text opacity=1, rounded corners, inner sep= 0em, outer sep=0em]{test};
\end{tikzpicture}
% alignment is shifted vertically
\begin{tikzpicture}
\node[text width=\textwidth, text centered,fill=yellow, fill opacity=0.4,text opacity=1, rounded corners, inner sep= 0em, outer sep=0em]{\begin{itemize}
\item test
\end{itemize}};
\end{tikzpicture}
\end{frame}
You can workaround the problem like this:
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
% alignment is correct without using itemize
\begin{tikzpicture}
\node[text width=\textwidth, text centered,fill=red, fill opacity=0.4,text opacity=1, rounded corners, inner sep= 0em, outer sep=0em]{test};
\end{tikzpicture}
\bigskip
% alignment is shifted vertically
\begin{tikzpicture}[baseline]
\node[text width=\textwidth, text centered,fill=red, fill opacity=0.4,text opacity=1, rounded corners, inner sep= 0em, outer sep=0em]{\begin{minipage}{\textwidth}\begin{itemize}
\item test
\end{itemize}\end{minipage}};
\end{tikzpicture}
\end{frame}
\end{document}

circuitikz - move current labels closer to current arrow

how can I move the current label closer to the current arrow. I.e. I want to move the i_1 closer to the arrow.
MWE:
\documentclass{standalone}
\usepackage[european,cuteinductors,fetbodydiode,straightvoltages]{circuitikz}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}[scale=0.65, arrowmos]
\coordinate (zero) at (0,0);
\draw (zero) to[R,-*,R=$R_1$,i>_=$i_1$] ++(2.75,2);
\end{tikzpicture}
\end{figure}
\end{document}
I tried to put a \vspace in front of the label but it didn't work.
I propose two solutions here: the first one is using a fake label and then setting the label manually (with a lot of flexibility), or using the provided styling for labels. Details in comments; you need a quite recent circuitikz for using this solution (>=1.4.2).
\documentclass{standalone}
\usepackage[european,cuteinductors,fetbodydiode,straightvoltages]{circuitikz}
\begin{document}
\centering
\begin{tikzpicture}[scale=0.65, arrowmos]
\coordinate (zero) at (0,0);
% First option
% use a blank label for the current, and name the component
\draw (zero) to[R,-*,R=$R_1$,i>_=~,name=myI] ++(2.75,2);
% manually place the label where you like
% myIcurrent is the normal position where the blank label is set
\node[below=1mm, anchor=center, red] at (myIcurrent) {$i_1$};
% you can also use bipole current style to change inner sep;
\draw (2,0) to[bipole current style={inner sep=0pt}, R,-*,R=$R_1$,i>_=$i_1$] ++(2.75,2);
\end{tikzpicture}
\end{document}
See circuitikz manual, https://texdoc.org/serve/circuitikz/0#subsection.5.6 .

Ignore margins and wrap text when adding pictures in Latex

I would like to add images in the top left/right or bottom left/right in a two-column page while ignoring the margins and having the text wrap around the picture. How can I also extend the solution to include half page images while ignoring the margins and with text wrapping.
I tried tikz package, but the text doesn't wrap around even when I use the wrapfig package.
For example, this is the code I used to insert image on the top left side of the page:
\documentclass[twocolumn, 12pt]{book}
\usepackage{lipsum}
\usepackage{tikz}
\begin{document}
\lipsum[1-3]
\begin{tikzpicture} [remember picture, overlay]
\node[anchor=north west,yshift=-1.5pt,xshift=1pt]%
at (current page.north west)
{\includegraphics[width=0.5\paperwidth,height=0.5\paperheight]{example.jpg}};
\end{tikzpicture}
\lipsum[1-3]
\end{document}
This results in the picture at the desired position, but the text is obscured behind the image. Thank you!
Not very pretty, but does the job I think (using geometry package only to get the correct values for top margin):
\documentclass[twocolumn, 12pt]{book}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{geometry}
\begin{document}
\begin{tikzpicture} [remember picture, overlay]
\node[anchor=north west]%
at (current page.north west)
{\includegraphics[width=0.46\paperwidth,height=0.5\paperheight]{example.png}};
\end{tikzpicture}
\vspace*{\dimexpr(0.5\paperheight-\voffset-1in-\headsep-\headheight)}
\lipsum[1-3]
\lipsum[1-3]
\end{document}

How can I force a tikz image to go to the bottom of the page?

I'm using this code to implement a "background image" on my page:
\tikz[remember picture,overlay] \node[inner sep=0pt] at (current page.center){\includegraphics{Images/picture.pdf}};
However, I'd like it to show up at the bottom of the page. I've tried changing the current page.center and played around with \vfill but I can't quite figure it out.
Something along the lines of this answer may be what you are looking for (adapted for this question):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{graphicx}
\begin{document}
\begin{titlepage}
\begin{tikzpicture}[overlay, remember picture]
\node[anchor=south west, %anchor is bottom left corner of the graphic
xshift=5cm, %shifting around
yshift=-5cm]
at (current page.south west) %left bottom corner of the page
{\includegraphics[width=5cm]{tiger}};
\end{tikzpicture}
\end{titlepage}
\end{document}

Resources