This question already has an answer here:
How to add a gif/animation onto Beamer (post Adobe retiring Flash)
(1 answer)
Closed 26 days ago.
I'm writing a latex file on Overleaf and I would insert a gif image.
Is it possible? Because I didn't find any solutions.
I had the same problem and I solved it by converting the gif to a set of pngs and then using the animate package.
For the first task you can exploit one of the solution suggested here.
Once you have a series of image files named with a shared prefix (e.g. fig-) and an increasing index that track the order in which they have to appear, then the usage of `animate} is pretty simple:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx, animate}
\title{animate SO}
\date{January 2022}
\begin{document}
This is how to insert gif in main document:
% use the usual figure environment and substitute \includegraphics with \animategraphics
\begin{figure}
\centering
% \includegraphics{}
\animategraphics[width=\textwidth, loop, autoplay]{1}%frame rate
{figures/fig-}%path to figures
{1}%start index
{4}%end index
\caption{Local gif}
\label{fig:my_label}
\end{figure}
\end{document}
Notice that I needed to express the path to the location of the figures as./figures/<fig-prefix> in case the \animategraphics is called by an external tex file which is included in the main.
I created a sample overleaf project to showcase the usage.
Finally, I'd suggest have a look to StackExchange LaTeX for latex related question :)
Related
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.
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.
I want to know if there is an easy way to extract the captions of one latex file with the numbers of the figures they are from.
For example if I have 3 figures in defined in my latex file, I need to create a document with the captions of those figures, e.g.,
Fig. 1. Caption of Fig. 1
Fig. 2. Another caption
Fig. 3. Yet another caption
Is there any way of doing this using latex? or should I do it with other program?
I have several figures, so I don't want to go and extract the captions one by one, because I have to number them manually.
Solution.
I solve the problem with a work around. I use another file to include the list of figures and process them separately. The file that I included contains a modified list of figures as follows
{\renewcommand*\numberline[1]{Fig.\,#1:\space}
\makeatletter
\renewcommand*\l#figure[2]{\noindent#1\par}
\makeatother
\listoffigures}
Then, I include it in the original file with \include command. Then it creates the list of figures file as file.lof, I used that file to compile a minimal file to produce the list of figures separately.
\documentclass{article}
\usepackage{subfigure} % This avoids problems with subfigures captions
\usepackage{amsmath,amssymb} % I used math in my captions
\nofiles % This makes the aux and lof file not to be deleted
\begin{document}
\include{list} % Includes the same file as before
\end{document}
I was using a different class, other than article, therefore, I need to copy some redefinitions in the auxiliar file. Rename the file.lof to this new file, so latex find it and it will do the work. I put all this in a script and now it works automatically.
Hth.
The \listoffigures control sequence may help you.
I have fairly large Latex document with a lot of TikZ figures inside. I have a habit of frequent recompilation and it takes forever to compile it using pdflatex. Figures in TikZ take most of the time.
My question is what is the best way to split the document into separate tex files (figures/chapters) to achieve separate compilation of figures and chapters, separate chapter pdfs, and a whole document pdf file ?
Have you tried compiling each picture on its own and then including them in your tex file as pdf rather than the tikz code? You can use the package standalone so that the picture will be the exact size you need. So :
\documentclass{standalone}
\usepackage{tikz,pgf} %and any other packages or tikzlibraries your picture needs
\begin{document}
\begin{tikzpicture}
%your tikz code here
\end{tikzpicture}
\end{document}
The good thing about this is that you can either include the compile this document directly to get a pdf figure to include in your document, or you can use the command \input to include it in your main document as a tikz code by adding
\usepackage{standalone}
in your main document (together with the tikz packages and libraries), and then
\begin{figure}
\input{tikzfile.tex}
\end{figure}
There is a possibly better way (imho) to cache tikz-pictures. Add the following lines in your
preamble:
\usetikzlibrary{external}
\tikzexternalize[prefix=i/]
After a pdflatex-run you'll see all pictures in the subdirectory ./i .
If you update the code of a tikz-picture simply throw away its corresponding pdf-file and it will be regenerated. For more info see the manual of PFG/TikZ section 32.4 Externalizing Graphics
and possibly 32.5 Using External Graphics Without pgf Installed.
How about putting each chapter in a separate file and then using \include to put them into some master file? Then you can use \includeonly to only compile the chapter you're currently working on. That should save some time at least.
I expect some sort of makefile based solution would be even better than this, but I don't know anything about makefiles...
The way I generally do this is to apply Latex to just part of the file: Emacs and several other Latex editors allow you to compiler regions: with Auctex, you can run TeX-pin-region to specify the current chapter, and then TeX-command-region to run Latex on the selected region.
The traditional way to do this is cut parts of the big file into smaller parts that are \included, and then either comment out parts you don't want to work on, or put some macrology at the beginning and end of each file that allows them to be compiled separately.
I'm trying to include a simple glossary to my LaTeX document,
I already searched for something like that on google, but never got it running.
I would like to use glossary or glossaries.
how to write it in the text?
how to print it?
what to execute on which position?
Well, there is a glossaries package on CTAN. Read the pdf documentation.
Check if you already have it in your installation, if not install it, and put \usepackage{glossaries} in the preamble of you document and it will be available to you.
It looks like you need \usepackage{glossaries} and \makeglossaries in the preamble, and some number of \newglossaryentry and \newacronym calls (it is not immediately clear to me if these only go in the premble or can go in the document text). Finally, you will need one or more \printglossary calls in the text. Use \gsl to connect glossary entries on the argument with the pages they occur on.
Processing the file will have to include a call to makeglossaries followed by at least one more invokation of latex.
In addition to the samples mentioned in the documentation there is a Stack Overflow question which includes a minimal file making use of glossaries. You may be particularly interested in the acronym glossary.
There is a nice blog for beginners: LaTeX glossary and list of acronyms
Here is an example:
\documentclass{article}
% Load the package
\usepackage{glossaries}
% Generate the glossary
**\makeglossaries**
\begin{document}
%Term definitions
\newglossaryentry{utc}{name=UTC, description={Coordinated Universal Time}}
\newglossaryentry{adt}{name=ADT, description={Atlantic Daylight Time}}
\newglossaryentry{est}{name=EST, description={Eastern Standard Time}}
% Use the terms
\gls{utc} is 3 hours behind \gls{adt} and 10 hours ahead of \gls{est}.
%Print the glossary
\printglossaries
\end{document}