1

Is there a way to copy LaTeX text out of TeXstudio with syntax highlighting? Will include some macros and small portions of LaTeX in a presentation (Powerpoint) and want to get it as readable as possible.

  • Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. – Martin Schröder Oct 16 '15 at 17:32
  • Most editors don't support copying text including syntax highlighting directly, but I don't know about TeXstudio (if you just google for "export syntax highlighting" you'll find some links to editors that do support it more or less, using some plugins, etc.). A workaround is, of course, to just do a screen shot. But see this question for some problems you might encounter. – jarauh Oct 16 '15 at 19:19
  • Depending on your syntax highlighting solution, it may be possible to enable copy-pasting syntax-highlighted HTML from the generated PDF. – Raphael Mar 12 '17 at 09:32

2 Answers2

1

Well, a simple screen capture with enough zoom can do that, but.... really do you want a copy & paste in PowerPoint?

mwe

\documentclass{beamer}
\title{Listing Code}
\author{Jhon Doe}
\usepackage{listings}
\usepackage{xcolor}
\usetheme{Warsaw}
\lstset{language=[LaTeX]TeX,
numbers=left, numberstyle=\small\sffamily\color{gray}, numbersep=1em,
frame=single, framerule=1pt,
keywordstyle=\color{red!70!black},
commentstyle=\color{blue},
morekeywords={maketitle,apples},
%tabsize=4,
backgroundcolor=\color{yellow!10},
caption=Copy \& Paste from somewhere\ldots}
\begin{document}
\begin{frame}[fragile]{Some \LaTeX\ code}
\begin{lstlisting}{LaTeX}
% This must be before of \maketitle
\title{Listing with syntax}
\author{John Doe}
\date{today} 
% End of preamble
\begin{document}
\maketitle 
\tomatoes % Undefined control sequence
\apples
 ...
\end{lstlisting}
\end{frame}
\end{document}
Fran
  • 80,769
  • Thanks for your answer. Marked it as the answer because I finally decided to search for a good beamer theme for my presentations. Bye bye PowerPoint :). – Fabian Deitelhoff Oct 19 '15 at 10:11
0

You can export the source code as formatted HTML (Tools -> Convert Source To HTML ...). However, I don't know if PowerPoint can make use of it. If not, you'll probably have to use a screenshot.

Tim Hoffmann
  • 11,159