Latex: setting another directory for bibliography of natbib package (windows) - latex

How to declare a different directory than the working folder with the natbib package using Tex Studio (Windows)? There is a directory for all my bibliographies (BiblioX.bib), and I use multiple per document. The bibliography path is : C:\Users\User\Dropbox\PDF\Bib ,and the working folder is : C:\Users\User\Dropbox\R&D\Project\Article\Work_Article .
The following code works:
\documentclass[12pt, a4paper]{article}
%Bibliography
\usepackage{natbib}
\bibliographystyle{newapa}
\begin{document}
\bibliography{../../../../../PDF/Bib/Biblio1,../../../../../PDF/Bib/Biblio2}
\end{document}
The goal would be to be able to use instead:
\bibliography{Biblio1,Biblio2}
Therefore declare a directory that Natbib would recognize : C:\Users\User\Dropbox\PDF\Bib
I thought about using a variable (or a new command):
\def \BibPath {C:/Users/User/Dropbox/PDF/Bib}
\bibliography{\BibPath/Biblio1,\BibPath/Biblio2}
But it does not work with the Natbib drop menu allowing to select the reference when writing \cite{ in Tex Studio. Is there a way to change the default of where Natbib/Tex Studio looks for bibliography?
Thanks!

Related

Import packages latex from directory

Is it possibile in latex to import a package like IEEEtran which I don't have installed but I have inside a directory named IEEETran_dir?
For instance I would like to do something like
\usepackage{./IEEEtran_dir/IEEEtran}
\documentclass[10pt, conference, letterpaper]{IEEEtran}
\begin{document}
\end{document}
Basically like it was suggested in the comment the proper way to do so was to import the relative path of the package directly in the \documentclass statement.
\documentclass[10pt, conference, letterpaper]{./IEEEtran_dir/IEEEtran}
\begin{document}
\end{document}
Of course it's just a workaround for those cases where you cannot install it, but the correct way should be to install the package.

Modify latex template in Rmarkdown

Can I modify the default Latex template used by Rmarkdown to compile Rmd files to pdf with the beamer class?
I am asking because of the difficulties I encounter using \includepdf (from the pdfpages package). Inspecting the generated tex source suggests that the root problem is the ignorenonframetext option in \documentclass[ignorenonframetext,]{beamer}.
(It is not a viable option for me to manually change the tex source each time)
In short: I want to modify the "Rmd beamer Latex template" (if that exists) to change the default ignorenonframetext
You don't need to modify the template, you can use \includepdf like this:
---
output:
beamer_presentation:
keep_tex: true
header-includes:
- \usepackage{pdfpages}
- \setbeamercolor{background canvas}{bg=}
- \makeatletter\beamer#ignorenonframefalse\makeatother
---
test
``` {=latex}
\end{frame}
\includepdf[pages=1-10]{example-image-duck}
\begin{frame}
```
test
(the line \setbeamercolor{background canvas}{bg=} is necessary for beamer versions < 3.64, a patch has been added in 9e3bb9)

Define Latex packages in reST file

We used Docutils to produce reST document, and then make a TeX file via rst2latex.
In the rst file, we have added a lot of LaTeX code like:
.. raw:: latex
~\\
\rule{\textwidth}{1pt}
~\\
But I do not know where to add packages like \usepackage{tabulary}.
If I add it in the rst file like I've shown above, even in the very beginning, this \usepackage line is automatically added after \begin{document} in the tex output file. This obviously generates an error.
Any idea where can I add \usepackage commands in reST?
You can use the LaTeX preamble (after Docutils 0.7) by
rst2latex foo.rst foo.tex --latex-preamble="\usepackage{tabulary}"
which will generate the following in foo.html
%%% Custom LaTeX preamble
\usepackage{tabulary}
Alternatively, a custom stylesheet can be provided by
rst2latex foo.rst foo.tex --stylesheet=preamble.tex
which will generate
%%% User specified packages and stylesheets
\input{preamble.tex}
in the right place.

How do I use TrueType fonts with LaTeX

I need to use a font family in my LaTeX documents, that is available as 18 .TTF (TrueTypeFont) files.
Where do I have to copy the files in my MiKTeX 2.8 installation?
How Do I make the fonts available for LaTeX?
I usually use pdfLaTeX. I read in Truetype-Fonts in LaTeX that TTF fonts are available without creating all the .TFM files. What is necessary for this case?
Can I install the fonts in the local-texfm directory? I would like to isolate the system installation and my manually added stuff. Probably it would be easier to copy this font family on another installation.
The easiest way would be to use XeLaTeX, for which you would just install the fonts to your system. A basic template would look like this (from https://web.archive.org/web/20111115151939/http://theotex.blogspot.com/2008/04/what-is-xetex-basic-template_15.html) :
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[10pt]{memoir}
\usepackage{xltxtra,fontspec,xunicode}
\defaultfontfeatures{Scale=MatchLowercase}
\setromanfont[Numbers=Uppercase]{Hoefler Text}
\setmonofont[Scale=0.90,Ligatures=NoCommon]{Courier}
\title{Your Title}
\author{Your Name}
\date{}
\begin{document}
\maketitle
\chapter{Title}
\section{Section Title}
Your text
\subsection{Subsection Title}
Your Text
\end{document}
If you want to stick to LaTeX, you can generally try these steps:
Create the TeX font metrics (tfm), the font description (fd) and the font mapping (map).
Using ttf2tfm to generate .vpl, then vptovf to create .tfm.
Put the files (ttf, tfm, fd, map) into the proper directories in the local texmf tree.
Update the TeX filename database.
Using texhash
Register the mapping.
Using updmap-sys
It seems rather straightforward, but there are many traps regarding the font description and mapping, as well as the naming scheme for the output files.
There are a lot of scripts and howtos which didn't work for me. So I wrote this tool to help me use ttf fonts with LaTeX: http://devnotcorp.wordpress.com/2011/06/10/use-truetype-font-with-pdflatex/.
Although it's many years later I thought of adding that if one uses LuaLaTeX, you don't need to do anything apart from using the LuaLaTex package fontspec and then in the preamble of in the document \setmainfont{ComicSansMS}.
Use ttf2tfm and ttf2pk programs
try the following: http://www.radamir.com/tex/ttf-tex.htm. I tried it several YEARS ago; i found some bugs but I can't remember them anymore. I think it had something to do with wrong files being used with another program. The author had SWITCHED file extensions due to confusion because of the number of files being generated. I notified the author about it but I don't know if he had corrected it.

Compiling LaTeX via an on-line server

I have a LaTeX text document that compiles fine with the current version of pdflatex on my home computer. I've made minor edits to the body of the document. I'm trying to recompile it, using either http://sciencesoft.at/latex/?lang=en or the first google result for the words "latex to pdf online." (I can't post the hyperlink due to spam prevention.) The former site is running pdfTeXt; the latter, MikTeX. I've pasted my headers below. Does anyone know how I might change them to make either one work?
Thanks,
-- Mark
\documentclass{article}
\usepackage{setspace}
\pdfpageheight 11in
\pdfpagewidth 8.5in
\doublespacing
\usepackage[top=1in,bottom=1in,left=1in,right=1in]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\headheight{15pt}
\fancyhead[R]{My name}
\fancyfoot[C]{\thepage}
\begin{document}
\section*{Finite Simple Groups}
...text...
\end{document}
Looking at the output, I saw the problem was with the \headheight command. Googling for that suggests you should change it to \setlength\headheight{15pt}. This makes it work with the sciencesoft tool!

Resources