Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

It might not be possible to do this, but I was wondering if there is a way to doodle on top of the LaTeX output, or in my case on top of Sweave output.

See example underneath!!

normal output output with doodle

\begin{tikzpicture}
\node[right,text width=11.7cm,rounded corners,fill=blue!20,inner sep=1ex]{
\begin{center}
\textbf{EXERCISE \ex}
\end{center}
Let's create a random sample of 10 smaller case letters from the alphabet as follows:
<<>>=
test.letters <- sample(letters,10)
@
\begin{enumerate}
\item Create a factor out of this vector and inspect it.
\item What do you notice when inspecting the given levels of this factor?
\item How can you make sure that the whole alphabet is taken into account in the levels? \end{enumerate}
\vspace{.1in}};
\end{tikzpicture}

HERE'S THE PLAIN LATEX EXPORT

\batchmode
\makeatletter
\def\input@path{{\string"C:/Documents and Settings/LSDEMMLJ/Desktop/R intro v1.1/\string"/}}
\makeatother
\documentclass[british]{beamer}
\usepackage{mathptmx}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\bigskipamount}
\setlength{\parindent}{0pt}
\usepackage{amsmath}
\usepackage{amssymb}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
 % this default might be overridden by plain title style
 \newcommand\makebeamertitle{\frame{\maketitle}}%
 \AtBeginDocument{
   \let\origtableofcontents=\tableofcontents
   \def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
   \def\gobbletableofcontents#1{\origtableofcontents}
 }
 \def\lyxframeend{} % In case there is a superfluous frame end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{graphicx}
\usepackage{mdwlist}
\usepackage{xr}
\usepackage{units}
\usepackage{fancyhdr}
\usepackage{textcomp}
\usepackage{latexsym}
\usepackage{multicol}
\usepackage{dirtree}
\usepackage{keystroke}
\usepackage{url}
\usepackage{hyperref}

\usetheme{Madrid}
\makeatletter
\defbeamertemplate*{title page}{mytitlepage}[1][]
{
  \vbox{}
  \vfill
  \begin{centering}
    \begin{beamercolorbox}[sep=8pt,center,#1]{}
      \usebeamerfont{title}\inserttitle\par%
      \ifx\insertsubtitle\@empty%
      \else%
        \vskip0.25em%
        {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
      \fi%     
    \end{beamercolorbox}%
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center,#1]{author}
      \usebeamerfont{author}\insertauthor
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center,#1]{institute}
      \usebeamerfont{institute}\insertinstitute
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center,#1]{date}
      \usebeamerfont{date}\insertdate
    \end{beamercolorbox}\vskip0.5em
    {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
  \end{centering}
  \vfill
}
\makeatother

\title[Intro to R \theframenumber]{An Introduction to the R Statistical Environment}
\author{Joanne Demmler}
\institute[Swansea University]{CIPHER\\ College of Medicine}
\date{5th of June 2013 \\{\tiny Version 1.2}}

\AtBeginPart{%
    {%  start a group to keep the template change local
        \setbeamertemplate{background canvas}{%
            \color{blue!20!white!80}\rule{\paperwidth}{\paperheight}%
        }%
        \frame{\partpage}%
    }%  end group
}

\hypersetup{pdfpagemode=None}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{decorations.pathreplacing}

\newcounter{bar}
\newcommand{\ex}{%
        \stepcounter{bar}%
        \thebar}

% add highlighting to text
\usepackage{color}
\newcommand{\hilight}[1]{\colorbox{yellow}{#1}}

\makeatother

\usepackage{babel}
\usepackage{Sweave}
\begin{document}
\begin{frame}[fragile,allowframebreaks]
\frametitle{Vector exercises}

\begin{tikzpicture}
\node[right,text width=11.7cm,rounded corners,fill=blue!20,inner sep=1ex]{
\begin{center}
\textbf{EXERCISE \ex}
\end{center}
Let's create a random sample of 10 smaller case letters from the alphabet as follows:
\begin{Schunk}
\begin{Sinput}
> test.letters <- sample(letters,10)
\end{Sinput}
\end{Schunk}
\begin{enumerate}
    \item Create a factor out of this vector and inspect it.
    \item What do you notice when inspecting the given levels of this factor?
    \item How can you make sure that the whole alphabet is taken into account in the levels?
\end{enumerate}
\vspace{.1in}};
\end{tikzpicture}
\end{frame}



\lyxframeend{}
\end{document}

AND THE LYX EXAMPLE:

#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413
\begin_document
\begin_header
\textclass beamer
\begin_preamble
\usepackage{graphicx}
\usepackage{mdwlist}
\usepackage{xr}
\usepackage{units}
\usepackage{fancyhdr}
\usepackage{textcomp}
\usepackage{latexsym}
\usepackage{multicol}
\usepackage{dirtree}
\usepackage{keystroke}
\usepackage{url}
\usepackage{hyperref}

\usetheme{Madrid}
\makeatletter
\defbeamertemplate*{title page}{mytitlepage}[1][]
{
  \vbox{}
  \vfill
  \begin{centering}
    \begin{beamercolorbox}[sep=8pt,center,#1]{}
      \usebeamerfont{title}\inserttitle\par%
      \ifx\insertsubtitle\@empty%
      \else%
        \vskip0.25em%
        {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
      \fi%     
    \end{beamercolorbox}%
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center,#1]{author}
      \usebeamerfont{author}\insertauthor
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center,#1]{institute}
      \usebeamerfont{institute}\insertinstitute
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center,#1]{date}
      \usebeamerfont{date}\insertdate
    \end{beamercolorbox}\vskip0.5em
    {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
  \end{centering}
  \vfill
}
\makeatother

\title[Intro to R \theframenumber]{An Introduction to the R Statistical Environment}
\author{Joanne Demmler}
\institute[Swansea University]{CIPHER\\ College of Medicine}
\date{5th of June 2013 \\{\tiny Version 1.2}}

\AtBeginPart{%
    {%  start a group to keep the template change local
        \setbeamertemplate{background canvas}{%
            \color{blue!20!white!80}\rule{\paperwidth}{\paperheight}%
        }%
        \frame{\partpage}%
    }%  end group
}

\hypersetup{pdfpagemode=None}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{decorations.pathreplacing}

\newcounter{bar}
\newcommand{\ex}{%
        \stepcounter{bar}%
        \thebar}

% add highlighting to text
\usepackage{color}
\newcommand{\hilight}[1]{\colorbox{yellow}{#1}}
\end_preamble
\use_default_options false
\begin_modules
beamer-fragile
sweave
\end_modules
\maintain_unincluded_children false
\language british
\language_package default
\inputencoding auto
\fontencoding global
\font_roman times
\font_sans default
\font_typewriter default
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100

\graphics default
\default_output_format pdf2
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry true
\use_amsmath 2
\use_esint 1
\use_mhchem 1
\use_mathdots 1
\cite_engine basic
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation skip
\defskip bigskip
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 3
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard
\begin_inset Flex FragileFrameAllowframebreaks
status open

\begin_layout Plain Layout
\begin_inset Flex FragileTitle
status open

\begin_layout Plain Layout
Vector exercises
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
begin{tikzpicture}
\end_layout

\begin_layout Plain Layout


\backslash
node[right,text width=11.7cm,rounded corners,fill=blue!20,inner sep=1ex]{
\end_layout

\begin_layout Plain Layout


\backslash
begin{center}
\end_layout

\begin_layout Plain Layout


\backslash
textbf{EXERCISE 
\backslash
ex}
\end_layout

\begin_layout Plain Layout


\backslash
end{center}
\end_layout

\begin_layout Plain Layout

Let's create a random sample of 10 smaller case letters from the alphabet
 as follows:
\end_layout

\begin_layout Plain Layout

<<>>=
\end_layout

\begin_layout Plain Layout

test.letters <- sample(letters,10)
\end_layout

\begin_layout Plain Layout

@
\end_layout

\begin_layout Plain Layout


\backslash
begin{enumerate}
\end_layout

\begin_layout Plain Layout


\backslash
item Create a factor out of this vector and inspect it.
\end_layout

\begin_layout Plain Layout


\backslash
item What do you notice when inspecting the given levels of this factor?
\end_layout

\begin_layout Plain Layout


\backslash
item How can you make sure that the whole alphabet is taken into account
 in the levels?
\end_layout

\begin_layout Plain Layout


\backslash
end{enumerate}
\end_layout

\begin_layout Plain Layout


\backslash
vspace{.1in}};
\end_layout

\begin_layout Plain Layout


\backslash
end{tikzpicture}
\end_layout

\end_inset
share|improve this question
    
Possibly related: tex.stackexchange.com/questions/20792/… –  John Wickerson May 8 '13 at 12:34
    
@JohnWickerson I think this only puts text on top of an image, what I really want is text or image on top of text. –  Joanne Demmler May 8 '13 at 12:38
    
I wonder if overprint is what you need. –  John Wickerson May 8 '13 at 12:46
1  
@JoanneDemmler Please provide a compilable Sweave file that contains this portion of your presentation. –  hpesoj626 May 8 '13 at 14:46
    
What exactly do you want? I'm using Sweave blocks in LyX. –  Joanne Demmler May 9 '13 at 10:15

1 Answer 1

up vote 4 down vote accepted

The LyX file you posted didn't work here, but it looks like you have the tikzpicture environment in an ERT. By adding some more TikZ code, you can do a lot of things, including the ellipses and text in your image. This method is a little impractical perhaps, as you have to try several times to get the position and size of the additions correctly.

First, you have to name the node, so change the first line of the tikzpicture to

 \node (block) [right, ...

The node will now be named block, and we can use it's corners as coordinates, and place stuff relative to that. Here I've simply used xshift and yshift to place the stuff relative to the lower left corner. (Another way could be to use a similar technique to what I describe in Highlight a table row with a rectangular overlay.)

\draw [red,very thick] ([xshift=3.55cm,yshift=3.65cm]block.south west) circle[x radius=.7cm,y radius=.3cm];
\node [red,right] at ([xshift=3.25cm,yshift=4.2cm]block.south west) {random sample and permutations, see \texttt{> ?sample}};

\draw [blue,very thick] ([xshift=4.9cm,yshift=3.65cm]block.south west) circle[x radius=.7cm,y radius=.3cm];
\node [blue,right] at ([xshift=3.9cm,yshift=3cm]block.south west) {26 lower case letters of the Roman alphabet};

The \draw lines draw ellipses (note the different x radius and y radius for the circle. As you may guess, block.south west is the lower left corner, and ([xshift=3.25cm,yshift=4.2cm]block.south west) is the point 3.25cm to the right, and 4.2cm above, this corner.

Here is the complete code for just this tikzpicture. I modified the code slightly, to get output similar to yours (I don't have the Sweave package).

\documentclass{standalone}    
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (block) [right,text width=11.7cm,rounded corners,fill=blue!20,inner sep=1ex]  {
\begin{center}
\textbf{EXERCISE 1}
\end{center}
Let's create a random sample of 10 smaller case letters from the alphabet as follows:
\begin{verbatim}
<<>>=
test.letters <- sample(letters,10)
@
\end{verbatim}
\begin{enumerate}
\item Create a factor out of this vector and inspect it.
\item What do you notice when inspecting the given levels of this factor?
\item How can you make sure that the whole alphabet is taken into account in the levels? \end{enumerate}
\vspace{.1in}};

\draw [red,very thick] ([xshift=3.55cm,yshift=3.65cm]block.south west) circle[x radius=.7cm,y radius=.3cm];
\node [red,right] at ([xshift=3.25cm,yshift=4.2cm]block.south west) {random sample and permutations, see \texttt{> ?sample}};

\draw [blue,very thick] ([xshift=4.9cm,yshift=3.65cm]block.south west) circle[x radius=.7cm,y radius=.3cm];
\node [blue,right] at ([xshift=3.9cm,yshift=3cm]block.south west) {26 lower case letters of the Roman alphabet};
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Very cool! Thanks - will try it when I get a quite minute! –  Joanne Demmler Aug 25 '13 at 21:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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