Latex/Miktex: Undefined citations - latex

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.

Related

Is it possible to insert a gif in latex (Overleaf)? [duplicate]

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 :)

overleaf standalone package (for multi-file projects) - subpreamble is not considered

I am building a multi-file latex project with overleaf, following this guide.
In short, I like moderncv title, and i want to use that together with a simple article to have my cover letter be consistent with my cv.
I tried setting up a main file
\documentclass[class=moderncv, crop=false]{standalone}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[utf8]{inputenc}
\usepackage[subpreambles=true]{standalone}
\usepackage{import}
\usepackage[scale=0.75]{geometry}
\renewcommand*{\namefont}{\fontsize{30}{29}\mdseries\upshape}
\name{Name}{Surname}
\title{Presentation Letter}
\address{Street n 1}{City}{Country}
\phone[mobile]{+42~(123)~456~6789}
\email{my#email.com}
\photo[64pt][0pt]{picture}
\begin{document}
\makecvtitle
\import{sections/}{presentation}
\end{document}
and in presentation.tex there is just
\documentclass[class=article, crop=false]{standalone}
\usepackage[utf8]{inputenc}
\setlength{\parindent}{0.5em}
\setlength{\parskip}{1em}
\renewcommand{\baselinestretch}{1.2}
\begin{document}
...presentation..
\end{document}
Unfortunately, while the moderncv title looks good, the imported presentation does not have the expected formatting (article + custom parindent, parskip, baselinestretch).
I would also like to point out that in order to compile, I had to revert the TexLive Version to 2016 (Overleaf V1 legacy), otherwise it wouldn't work at all.
I hope somebody can help me, or at least point me towards another direction, maybe supported by latest overleaf engine, to combine two different files with two different preambles. Thanks

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.

mathematica 8.0 and psfrag

I recently updated from mathematica 7.0 to 8.0, and have now encountered problem with replacing my plot labels with LaTeX code using the psfrag package. Everything worked perfectly with the earlier version and the exact same plots, but now psfrag leaves all the labels unchanged. I use Kile on Ubuntu 11.04 for LaTeX editing.
For example, in Mathematica:
plot = Plot[x, {x, -0.1, 0.1},
AxesLabel -> {eps, SUM}, BaseStyle -> {FontSize -> 10}]
Export["plot.eps", plot]
and then in LaTeX:
\begin{figure}
\psfrag{eps}{$\epsilon$}
\psfrag{SUM}{$\Sigma$}
\includegraphics{plot.eps}
\end{figure}
This should now replace labels with LaTeX typesetting, but nothing happens. Any suggestions how to solve this? Does anyone know if there is a difference in how Mathematica 8 encodes text in eps files compared to earlier versions?
There's no difference in how the EPS is encoded. The problem is that the PS code that makes the text in the v7 output (note that Mma uses bind def to create shortcuts for a lot of PS code, see the top of the generated EPS files for details):
%%IncludeResource: font Times-Roman-MISO
%%IncludeFont: Times-Roman-MISO
10 /Times-Roman-MISO Msf
0 8 m
(SUM) N
has been replaced in v8 with
%%IncludeResource: font Times-Roman-MISO
%%IncludeFont: Times-Roman-MISO
10 /Times-Roman-MISO Msf
p
0.75 9 m
(S) N
P
p
6 9 m
(U) N
P
p
14.25 9 m
(M) N
This means that psfrag can not grab hold of the tags.
I can't find how to fix this in the Mma export options.
At the moment, the only work-around I can think of (and I've tested that works) is to use single letter tags for the axes labels, e.g.
plot = Plot[x, {x, -0.1, 0.1}, AxesLabel -> {"e", "s"},
BaseStyle -> {FontSize -> 10}]
Export["plot8.eps", plot]
\begin{figure}[h]
\psfrag{e}{$\epsilon$}
\psfrag{s}{$\Sigma$}
\includegraphics{plot8.eps}
\end{figure}
Note:
The reasons for maybe wanting to use psfrag are well stated in http://www.reimeika.ca/marco/prettyplots/
Now, those tags don’t look too good
(and make little sense to boot).
However the idea is to ultimately
include the plot in a paper or report
made with LaTeX, and so the real point
to the tags is to use them as markers
for the psfrag package which allows to
replace text within EPS graphs. This
way of labeling has three big
advantages over hardcoding the tags
into the figure. First is consistency,
as the fonts will be the same as those
in the article. Second is the fact
that LaTeX's mathematical engine can
be used to the fullest extent within
the plot. Last but not least, it
allows changing notation easily within
the .tex file, as opposed to having to
recreate the plot from scratch.
Addendum:
The package psfrag only works with EPS graphics and thus only with latex.
If you want to use psfrag and pdflatex, then see the tex.SE question
Using psfrag with pdflatex
Tried both 7.0.1 and 8.0.1 and worked well for me. Hence, I cannot reproduce your error. (Maybe just a typo, case sensitivity etc.). Anyway, I agree that LateX modification is almost obligatory for publications. First I also used PSFrag, but very often I also don't like the positioning of the labels, especially if you place more complex expressions. Therefore I suggest an intermediate step via PSTricks. This looks something like this:
\documentclass[floatfig,isolatin,amsthm,amsmath,amsfont,amstext,12pt,fullpage,pslatex,amsref]{scrartcl}
\usepackage{amstext}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{float}
\usepackage{epic}
\usepackage{eepic}
\usepackage{color}
\pagestyle{empty}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(0,0)(13.0,7.8)
%\psgrid(0,0)(0,0)(13,7.8)
% need the grid only in the beginning for positioning
\rput[c](10.7,3.8){\includegraphics{plot.eps}}
% put labels.
\rput[c]{90}(9.5,4){\Large{$\frac{E^2_\text{tot}}{V M_\mathrm{S}}$}}
\rput[c]{0}(6,6.0){$x/h$}
% also to put extra lines, arrows, comments, etc. in LaTeX style, e.g.:
% \psline[linecolor=green,linewidth=2pt,linestyle=dashed]{->}(3.5,3.05)(9.1,3.05)
\end{pspicture}
\end{document}
So there is some work you have to do by hand, but usually it is worth the time as the result really looks better, especially if it is for publication. However, keep in mind that in standard settings LaTeX uses the Computer Modern Font for formulae. This is not identical with e.g. Times New Roman, the typical choice for text. You can change this with the mathptmx package.
You can write the "typeset" form in Mathematica directly, then it'll be already in the .eps file and you can just include the .eps as is.
plot = Plot[x, {x, -0.1, 0.1}, AxesLabel -> {"[\eps], [\Sigma]}, BaseStyle -> {FontSize -> 10}]
Just do [esc]+"eps"+[esc] and you'll get an epsilon, or insert it from the toolbox. Same for the sigma.

Extracting code from beamer presentation?

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.

Resources