ego_
ego_

Reputation: 1491

Shortcuts to \section in RStudio

Is it possible to create "shortcuts" to sections, subsection etc. in the Tex part of RStudio? Similar to the R part where wrapping a "title" in ##### Title ##### creates a drop down curtain right above the console window.

Upvotes: 1

Views: 522

Answers (2)

Thell
Thell

Reputation: 5958

You can use an empty code block. It will create the generation of the jump menu entries allowing the quick jumping and enable folding without altering output.

Jump Menu

Here's the toy contents...

\documentclass{article}
\usepackage{Sweave}
\SweaveOpts{concordance=TRUE}

\title{Sample Sweave Document}
\author{Thell Fowler}

\begin{document}

\maketitle

\section*{Introduction}
<<\section*{Introduction}>>=
@
Some actual content.


\section{Concept}
<<\section{Concept}>>=
@
Some other content.


\subsection*{Algorithm}
<<\subsection*{Algorithm}>>=
@
<<HelperFunctions>>=
HelperFunction1 <- function() {
  print( "That helped!")
}
HelperFunction2 <- function() {
  print( "Oh, that helped too!")
}
@

<<MainFunction>>=
main <- function() {
  print( "I need some help!")
  HelperFunction1()
  cat( "\tbut not enough!  Let's get more help...\n")
  HelperFunction2()
  cat( "That's much better!\n")
}
@

\subsection*{Example}
<<\subsection*{Example}>>=
@

<<Example>>=
# We can get help.
main()
@

\subsubsection*{Pros}
<<\subsubsection*{Pros}>>=
@

\subsubsection*{Cons}
<<\subsubsection*{Cons}>>=
@

\end{document}

It may look like a pain, but it's pretty direct and simple.
Followed by VIM Mode Keys

  1. Create section using the format dropdown, or just type it to keep hands on the keyboard.
  2. Copy the line, or which-ever part of it you want.
    0yE
  3. Create/Insert the code chunk.
    CTRL+Alt+I
  4. Paste the text between the inner <>.
    P
  5. Delete the blank line in the function, or add echo=FALSE to the definition.
    jdd

Upvotes: 2

Joe Cheng
Joe Cheng

Reputation: 8061

Sorry, no, this is not implemented in RStudio for Sweave/TeX docs.

Upvotes: 0

Related Questions