Extracting code from beamer presentation? - latex

Some years ago I created a Beamer presentation (using only basic features). Unfortunetaly, I've lost the source code but still have the output PDF. Is there a convenient way to extract the original code from the presentation? Simple copy methods does not handle the mathematics well.

No, I don't think it is possible to do that. LaTeX is a typesetting language, in which you say "put a section here, this text here, some formulae here, etc., and use this style file to weight the fonts and spacing" and then compile it to PDF. The PDF document tells the PDF viewer (loosely speaking): "here's the font, place these sets of characters at these places in the document". It has no notion of section/heading/figure/equation/equation number etc.
It would be very hard to do PDF->LaTeX because of the multiple possibilities. i.e., LaTeX->PDF is a many-to-one function, so the inverse operation is going to have ambiguities.
For e.g., here's a test file using two different methods:
\documentclass{article}
\begin{document}
This is a StackOverflow test file.
\section{Method A}
\begin{equation}
ax^2+bx+c=0
\end{equation}
\end{document}
\documentclass{article}
\begin{document}
This is a StackOverflow test file.\\[0.1in]
\noindent {\Large \textbf{1\quad Method B}}
\begin{center}
$\displaystyle ax^2+bx+c=0$
\end{center}
\vspace{-0.25in}
\hfill{(1)}
\end{document}
You can see that you can't tell the two documents apart. A PDF to LaTeX converter will face the same problems.
That said, some word processing applications (open office?) can interpret PDF documents (usually only if all text) and convert it to a word document, and then you can convert that into LaTeX (usually provided by the same application). This might be one option worth trying. Other than that, there is no software that I know of that will do this for you.

Related

Latex/Miktex: Undefined citations

I am writing a latex script for my work, and I am having infinite trouble in getting the references in the PDF. My code is shown below, and I am using MikTex 2.9 on RStudio. Some background information that might be relevant:
I am using Mendeley for my references, which I have set up correctly (as it seems) to Enable bibtex syncing
The .bib file doesn't seem to look strange to me (Irungu is added below)
I am using the exact same script as my colleagues (apart from the different path referring to my articles), and they are having no issues compiling it into pdf.
The errors regarding citations are:
Citation Draganovic2013 on page 1 undefined on input line xx
Citation Irungu2019 on page 1 undefined on input line xx
There were undefined citations
I hope one of you is able to help me out!
Cheers!
#article{Irungu2019,
abstract = {A composite blend consisting of sunflower cake, maize germ, wheat bran, fresh water shrimps and cassava flour was extruded using a single-screw extruder to produce expanded fish feed pellets. The effects of temperature (80–120 °C), die diameter (2–4 mm), and feed pre-conditioning time (50–150 s; steam 400 kPa) on properties of the pellets (expansion ratio, bulk density, floatability, durability, water absorption, water solubility, water stability, and in-vitro protein digestibility) were investigated using response surface methodology. Regression equations describing the effect of each variable on the product responses were obtained. The pellets extruded using a factor combination of 120 °C extruder barrel temperature, 2 mm die diameter, and 100 s of feed pre-conditioning time gave most desirable pellet floatability (100{\%}), durability index (99{\%}), expansion ratio (2.64), water absorption index (4.12), water solubility index (9.31), water stability (87{\%}), bulk density (479 g/L), and in vitro protein digestibility (69.97{\%}) with a composite desirability of 0.88. Practical applications: Extrusion is a modern feed processing method whose use is fast gaining popularity among small feed processors in developing countries. However, extrusion is a process that involves many parameters that need to be optimized for desirable end properties. These findings guide fish feed manufacturers on the optimum conditions for single screw extruders for production of feeds with desirable properties especially for the fish types that are top feeders. In addition, the results offer important insights on how temperature, die diameter, and feed pre-conditioning, may be manipulated to influence properties of extruded aquafeed when using simple low-cost small-scale extruders.},
author = {Irungu, Francis Gichuho and Mutungi, Christopher and Faraj, Abdul and Affognon, Hippolyte and Ekesi, Sunday and Nakimbugwe, Dorothy and Fiaboe, Komi K.M.},
doi = {10.1111/jfpe.12980},
file = {:L$\backslash$:/Marjanne/ScientificArticles/Irungu2019.pdf:pdf},
issn = {17454530},
journal = {Journal of Food Process Engineering},
number = {2},
pages = {1--12},
title = {{Optimization of extruder cooking conditions for the manufacture of fish feeds using response surface methodology}},
volume = {42},
year = {2019}
}
\documentclass[10pt,a4paper]{article}
\usepackage{etoolbox}
\usepackage{mathpazo}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\ttdefault}{lmtt}
\usepackage{geometry}
\usepackage[usenames,dvipsnames]{xcolor}
% \geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2.5cm,rmargin=2.5cm}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2.5cm,rmargin=2.5cm}
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=colon]{caption}
\usepackage{amstext}
%% \usepackage{esint}
\usepackage[english]{babel}
\usepackage{eurosym}
\usepackage{booktabs}
\usepackage[parfill]{parskip}
\usepackage[round]{natbib}
%\usepackage{caption}
\usepackage{pdfpages}
\usepackage[figuresright]{rotating}
\usepackage{longtable}
\usepackage[version=4]{mhchem}
\usepackage{todonotes}
\usepackage{hyperref}
\usepackage{subfig}
\usepackage{array}
\usepackage{float}
\usepackage{lipsum}
\usepackage{lastpage}
\usetikzlibrary{patterns}
\usetikzlibrary{shapes.geometric}
\usepackage{textcomp}
\begin{document}
\title[Title of Document]
\begin{document}
\begin{titlepage}
\maketitle
\end{titlepage}
\section {Introduction}
Introduction is written here, but not relevant for this question.
\section {Background}
Here I write some text and refer to an article of Draganovic from 2013 \citep{Draganovic2013}. \\
In another section, I would like to refer to Irungu from 2019 \citep{Irungu2019}.\\
Current project will investigate the possibilities to re-evaluate Sustainable Fiber Technology's Wheat Straw Co-Product, by using it as a (partial) replacement of wheat gluten and/or starch in aquafeed. Being relatively high in lignin (20 - 40\% based on 30 - 50\% solids), the product is a potential excellent binder.
\section {Rest of the document}
Doesn't pose any significant errors.
\bibliographystyle{plainnat}
\bibliography{C://Users/Marjanne/Documents/April8/library}
\end{document}
I have not any problems with this LaTeX code (even if I use a Mac): there are anyway a couple of problems within your code:
The title is given as \title[Title of Document] and not as \title{Title of Document}
There are 2 \begin{document}: I do not know if this is just a typo when you copied your code here
Are you sure that the path of your .bib file is correct? I suggest to write just \bibliography{library} and put the library.bib file in the same directory of the tex file on which you are working on.
Moreover, have a look also at https://tex.stackexchange.com/ for questions about Tex, LaTeX.
EDIT: Make sure that you are compling your tex files with
pdflatex (or latex)
bibtex
pdflatex (or latex)
pdflatex (or latex)
run first pdflatex "file" -interaction=nonstopmode
then
biber "file"
then again
pdflatex "file" -interaction=nonstopmode
Should work
Even though the correct reference/citation was called from the bib file, the output generated a question mark in some cases. After making sure all files ended with .tex separately and in the main + checking if the reference file had a .bib extension, it worked however. In one case, simply renaming a file seemed to do the job.

How to include a LaTeX paper into another LaTeX paper in OverLeaf?

I have LaTeX paper that I need to include in my dissertation. I am working in OverLeaf. That paper was written under one document class while the university has its own class. I need to include the paper in the dissertation so that it has the university style, its images need to be listed in the list of figures of the dissertation, and the authors listed in the paper's bibliography needs to be listed in the university's class bibliography. Is there any way I can do that in OverLeaf?
There are several dedicated packages for this. For example have a look at the combine, subdocs or docmute packages (A list with even more suggestions can be fond at https://www.ctan.org/recommendations/docmute).
Here a short example with the docmute package
\documentclass{book}
\usepackage{lipsum}
\usepackage{docmute}
\begin{document}
\tableofcontents
text
\chapter{imported paper}
\input{test}% assuming your paper is called test.tex
\end{document}
A Latex document cannot have multiple \documentclass. One solution would be to split the header/content of your latex document in overleaf:
Create a master.tex with the documentclass and put all your content (text between \begin{document} and \end{document} in a second content.tex. In the master, just \input{content}.
In your dissertation, just copy content.tex, its figure and add \input{} in the master file of your University which has the specific documentclass and bibliography settings.

How to include both Agda and Isabelle code in the same latex file?

I am creating presentation slides using beamer, and on the slides I want to include pieces of code from Agda and Isabelle standard libraries. All I can find online is generating latex from Agda (lagda) or from Isabelle (document preparation). I want to go the other way, as my slides will have code from different systems.
I can still use lstlisting or verbatim, but I would rather not copy-paste and reformat code.
I would prefer to have something like including line numbers from files, or maybe code between tags
Your best bet is to use the catchfilebetweentags package: given two files IsabelleCode.tex and AgdaCode.tex generated by the respective LaTeX backends of each language, you can capture the code between an opening tag %<*TAGNAME> and a closing tag %</TAGNAME> in either file by using the appropriate directive e.g.:
\ExecuteMetaData[IsabelleCode.tex]{TAGNAME}
\ExecuteMetaData[AgdaCode.tex]{TAGNAME}
With \lstinputlisting from the listings package, you can directly include code from the source file. Optionally you can specify the start and end line numbers
\documentclass{beamer}
\usepackage{listings}
\lstset{basicstyle=\ttfamily}
\begin{document}
\begin{frame}[fragile]
\lstinputlisting[firstline=1,lastline=7,language=C]{duck.C}
\end{frame}
\begin{frame}[fragile]
\lstinputlisting[firstline=1,lastline=7]{test.agada}
\end{frame}
\begin{frame}[fragile]
\lstinputlisting[firstline=1,lastline=7]{test.isabelle}
\end{frame}
\end{document}
At least for Agda, you can render individual .lagda modules into LaTeX. If you can do the same with Isabelle's pretty-printer, you should be then able to write toplevel LaTeX by hand, and then import (parts of) the Agda and Isabelle-generated LaTeX where appropriate.

How can I use org-mode to write LaTeX for scientific journals?

I write most text using org-mode nowadays, and I often use it to generate PDF via LaTeX (xelatex, specifcally). But now I want to use it to write scientific articles, and journals often want me to use a specific style. This includes a .cls-file, which is easy enough using org-latex-classes, but quite often, they require a specific setup following \begin{document} (i.e. a specific abstract section, funky author and affiliation, etc, and I don't see how to do that. That is, I now do this within a #+begin/end_latex section - but this needs to be completely rewritten if I switch style.
I realize I probably need to fiddle with the LaTeX code at some point, but I'd like to minimize this fiddling as far as possible, and I'd like to be able to switch from one journal to another with a minimum of fuss, and keeping my org-mode source as intact as possible.
See item 3 at http://kitchingroup.cheme.cmu.edu/blog/2014/08/08/What-we-are-using-org-mode-for/
There is a list of papers there we have written in org-mode and exported to LaTeX. We have probably 8 more since that post.
In the SI you can find the org-source embedded in the PDF, and here: Spencer D. Miller, Vladimir V. Pushkarev, Andrew J. Gellman and John R. Kitchin, Simulating Temperature Programmed Desorption of Oxygen on Pt(111) Using DFT Derived Coverage Dependent Desorption Barriers, Topics In Catalysis, 57(1), 106-117 (2013). http://link.springer.com/article/10.1007%2Fs11244-013-0166-3 you can even find our manuscript embedded.
You may also want to checkout https://github.com/jkitchin/org-ref for citation management and https://github.com/jkitchin/jmax/blob/master/ox-manuscript.el for how we do our exports.
Depending on the amount of latex polishing you need to do, you may find it simpler to just add some things to your org file, and use a little bit of babel directly. Here is a snippet of how the start of one my files might look. Some of things are in there, because I will also have the R code for the statistical analyses in the org file in order to be able to have a more reproducible work flow:
# -*- mode: org; org-export-babel-evaluate: nil -*-
#+Title: This is my title
#+Author: An Author, Another Author, and Last Author
#+Options: toc:nil ':t *:nil -:nil ::nil <:nil ^:t author:t d:t H:5 |:t
#+Property: header-args:R :session *myarticlessection* :results output :exports both :cache yes
#+Latex_Class: article
#+Latex_Class_Options: [12pt]
#+Latex_Header: \usepackage{amsmath}
#+Latex_Header: \usepackage[T1]{fontenc}
#+Latex_Header: \usepackage{mathptmx}
#+Latex_Header_Extra: \linespread{1.5}
#+LATEX_HEADER: \usepackage[citestyle=authoryear-icomp,bibstyle=authoryear, hyperref=true,backref=true,maxcitenames=3,url=true,backend=biber,natbib=true] {biblatex}
#+Latex_header: \addbibresource{myarticles.bib}
#+BEGIN_SRC latex :results output
\begin{abstract}
Here is where I put the abstract.
\end{abstract}
#+END_SRC
#+RESULTS:
#+BEGIN_LaTeX
\begin{abstract}
And this is where it ended up after evaluating the babel block.
\end{abstract}
#+END_LaTeX
I used org-mode to write several papers, including my PhD thesis. It helped me greatly to keep track of open problems, priorities, annotations etc.
I use a small custom converter that reads the .org file and exports parts of it to a .tex file. Note that "normal" org-mode text (including headings, text, priorities, keywords etc.) is not exported, just the stuff between #BEGIN_LaTeX and #END_LaTeX tags. This way, you can make annotations as you see fit, which won't appear in the published text.

Latex template for quickly writing summaries of courses

For some courses I take, we are allowed to write a summary and to used it at the exam. The summary allowed is usually limited to something like ten A4 pages. I quickly googled for latex templatex, but I couldn't find anything useful so far.
The template should allow to used the full space available on an A4 paper, by default latex documents usually have large borders. I guess I'm not the first person looking for this kind of template, so please post any links if you know good templates.
You can setup your margins pretty easily using the geometry package (which should be part of most latex distributions I believe) http://ctan.org/tex-archive/macros/latex/contrib/geometry/
You'll probably also need one of the multiple column layouts and amsmath packages.
You can find a bunch of details on page layout here: http://en.wikibooks.org/wiki/LaTeX/Page_Layout
I'd probably use something like this:
\documentclass[a4paper]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{amsmath}
\usepackage{multicol}
\begin{document}
\begin{multicols}{3}
... MY STUFF HERE ...
\end{multicols}
\end{document}
EDIT: Original version was trying to use the plain style, which seems to not exist. Also had the usepackages inside the document rather than the preamble, and had some spelling mistakes. Won't look useful until you fill it with some stub data... head over to lipsum.com for some filler text.

Resources