kable function with encoding (polish signs) in R - r

I use knitr::kable function to dynamicly print tables in pdf with latex.
the problem is that in the table there are polish signs, which are encoded for example:
'Galeria Mokotów' is encoded into 'Galeria MokotĂłw' and my '.Rnw' file fails.
how should I change the preamble to fix pdf printing?
\documentclass[10pt,a4paper]{res}
\usepackage{helvet}
\usepackage[cp1250]{inputenc}
\usepackage{fontenc}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage[table]{xcolor}
\usepackage[pdfstartview=FitB]{hyperref}
\usepackage{float}
\usepackage{polski}
\usepackage{layout} % show a page layout
\usepackage{blindtext} % dummy text
\begin{document}
\end{document}

Related

Text inside of align environment

I am currently facing a small problem inside of align environment, which is the the space between words. As you can see in the following figure, the words are close to each other, and the space that is mentioned in the code, are not considered inside of align environment. I would like to know how can I solve this problem and make words more clear like the ones we tend to see in paragraphs.
enter image description here
Here is the code of the mathematic Presentation mentioned above.
\documentclass[a4paper,12pt]{report}
\usepackage[french]{babel}
\usepackage[export]{adjustbox}
\usepackage{enumitem}
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{fancyhdr}
\usepackage{caption}
\usepackage{booktabs, multirow}
\usepackage{soul}
\usepackage[table]{xcolor}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\begin{document}
\begin{align*}
{\displaystyle \gamma_{b} = \quad \left\{{\begin{array}{l} 1.5 \quad (Situation Durable ou Transitoire) \\ 1.15 \quad ( Situation Accidentelle) \end{array}}\right.}
\end{align*}
\end{document}

I am getting error "command \bibname unspecified" while compiling a latex document in R markdown

I am trying to create an R Markdown Template on the basis of a LaTeX template I found on Overleaf. The template preamble uses many packages. I am trying to compile this latex file in RStudio using tinytex latex compiler, and during this process, I am getting error "Latex Error: Command \bibname unspecified. I am attaching both, the preamble from overleaf, and the YAML specification from R Markdown.
Overleaf Preamble
\documentclass[twoside]{report} %[twoside, 14pt]
% ==== MY BUNCH OF PACKAGES ====
\usepackage[a4paper,top=3cm,bottom=3cm,left=2.5cm,right=2.5cm,bindingoffset=5mm]{geometry}
\usepackage[english]{babel}
\usepackage{textcomp}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{multirow}
\usepackage{float}
\usepackage{amsmath}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{caption}
\captionsetup{font=footnotesize}
\usepackage{subcaption}
\usepackage{tabularx}
%\usepackage{mathabx}
\usepackage{subfiles}
\newcommand\quoteref[1]{\csname#1\endcsname}%
\usepackage{glossaries}
\usepackage[toc,page]{appendix}
\usepackage{rotating}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{changepage} % for the adjust width environment
\usepackage{setspace}
% ----------- code environment settings
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset{style=mystyle}
% ---------------- chapter abstracts
\newenvironment{chapabstract}
{
\begin{center}
\noindent\makebox[0.8\linewidth]{\rule{0.8\paperwidth}{0.4pt}}
\end{center}
\vspace{2mm}
\list{}{
\setlength{\leftmargin}{1cm}
\setlength{\rightmargin}{\leftmargin}
}
\item\relax
}
{\par}
\makeatother
% ------------- hyperref
%\biboptions{authoryear,square,sort&compress}
\usepackage[colorlinks=true,linkcolor=blue,citecolor=blue]{hyperref}
% -------------- journals shortcuts
\newcommand{\aaa}{Anonymous Ambiguous Abstracts}
\newcommand{\bbb}{Boring Bibliographic Book}
% ----------- glossary entries for summary of acronyms
\makenoidxglossaries
\newglossaryentry{AAA}{name=AAA, description={Ambitious Amicable Ants}}
\newglossaryentry{BBB}{name=BBBB, description={Babbling Bumbling Band of Baboons}}
\newglossaryentry{CCC}{name=CCC, description={Condescending Critical Cucumber}}
\newglossaryentry{BFG}{name=BFG, description={Big Friendly Giant}}
% ==== TEMPLATE PACKAGES ====
\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc} % use 8-bit T1 fonts
\usepackage{lmodern}
\usepackage{hyperref} % hyperlinks
\usepackage{url} % simple URL typesetting
\usepackage{booktabs} % professional-quality tables
\usepackage{amsfonts} % blackboard math symbols
\usepackage{nicefrac} % compact symbols for 1/2, etc.
\usepackage{microtype} % microtypography
\usepackage{lipsum} % fill with latin nonsense
YAML Specification in R Markdown
title: "Ambra2"
author: "Maulik Bhatt"
date: "`r Sys.Date()`"
output:
bookdown::pdf_document2:
template: Ambra.tex
keep_tex: true
Bibliography: references.bib
What am I doing wrong here?

Implementing R code in a LaTeX document with Sweave. Characters like é and è won't display correcty

I always use the bable (french) package and it works fine when one Overleaf or MiKTex. However, when copy pasting my code to Rstudio (with Sweave etc), it just does not work properly.
Document with "é" when done with Sweave
Same document (code copy pasted) on MiKTex
I have following packages:
\documentclass[a4paper, parskip=full]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{array}
\usepackage{tensor}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{verbatim}
\usepackage{enumitem}
\usepackage[abbrev,backrefs]{amsrefs}
\usepackage{appendix}
Since I don't know much about Rstudio, I don't know what information you need about it. I will provide more info when asked for.
I followed a simple tutorial on youtube to get sweave working.
Thank you.
Edit:
Here is a minimal document.
(not sure how to link the whole pdf)
The code in Rstudio (Sweave) is following:
\documentclass[a4paper, parskip=full]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{array}
\usepackage{tensor}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{verbatim}
\usepackage{enumitem}
\usepackage[abbrev,backrefs]{amsrefs}
\usepackage{appendix}
\title{Année académique}
\date{}
\begin{document}
\SweaveOpts{concordance=TRUE}
\maketitle
This is a sentence with the characters é and è.
\end{document}

Reference to R object inside a Latex (Sweave) document?

I need to generate some pdf files containing a series of images. In each pdf file, the order of images is different. Can I have an R file with the path and name of images and to reference this object inside Latex code?
This is my Latex code:
\documentclass[a4paper,landscape]{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{lscape}
\usepackage{rotating}
\usepackage{epstopdf}
\usepackage{xcolor}
\pagecolor{black}
\geometry{a4paper, landscape, margin=0.15in}
\begin{document}
\begin{figure}
\centering
\subfloat{\includegraphics{FF_0.png}}\hfill % instead of "FF_0.png" use objects[1]
\subfloat{\includegraphics{FF_0.png}}\hfill
\subfloat{\includegraphics{FF_0.png}}\hfill
\subfloat{\includegraphics{FF_0.png}}\hfill
\subfloat{\includegraphics{FF_0.png}}\hfill
\subfloat{\includegraphics{FF_0.png}}\hfill
\subfloat{\includegraphics{FF_0.png}}\hfill
\subfloat{\includegraphics{FF_0.png}}\hfill
\end{figure}
\end{document}
I would like to create an R chunk where I put an object like this objects <- c("FF_0.png", FF_2.png, etc.) and use inside latex code the object with indexing objects[1]
Could it be possible?

Error when \% is included in a sectioning command

When I try to input a \% in a \subsection's title and Compile pdf, I get the following error:
File ended while scanning use of \##BOOKMARK.
How should I do it?
EDIT
Here is a reproducible example. The file is encoded in UTF-8 format.
\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage{hyperref}
\usepackage{longtable}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{lscape}
\usepackage[normalem]{ulem}
\setmainfont[Scale=1.0]{Times New Roman}
\setsansfont{Times New Roman}
\begin{document}
\section{Μέσες τιμές και 95\% Διαστήματα Εμπιστοσύνης}
\subsection{a \% b cd}
<<>>=
1+1
#
\end{document}
It is perhaps a configuration problem of hyperref. I do not have Times New Roman, but I succeeded with xelatex (TeXLive 2012, Ubuntu 13.04) in RStudio (v0.98.312) and knitr using the configuration below:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{DejaVu Serif}
\usepackage[unicode=true,bookmarks=true,bookmarksopen=true]{hyperref}
\usepackage{xunicode}
\begin{document}
\section{Μέσες τιμές και 95\% Διαστήματα Εμπιστοσύνης}
\subsection{a \% b cd}
<<>>=
1+1
#
\end{document}
Output:
The document is UTF8 encoded. You probably need to tell hyperref the unicode option.

Resources