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.
Related
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?
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}
I want to create tables with the huxtable package in documents created with the thesisdow package. Knitting to html works well with HTML. But knitting but to PDF fails with the following error as soon as a table is included after loading huxtable:
! LaTeX Error: Environment threeparttable undefined.
There seems to be a clash with LaTex packages in the background.
Below a MWE for the thesisdown index.file.
Interestingly, in a simple markdown file knitting both to html and PDF works without problems.
Since thesisdown is built on bookdown it is possible that the error also occurs when knitting bookdown files to PDF.
index.Rmd
---
knit: "bookdown::render_book"
site: bookdown::bookdown_site
output:
thesisdown::thesis_pdf: default
# thesisdown::thesis_gitbook: default
---
```{r include_packages, include = FALSE}
# Ensure that the thesisdown package is installed and loaded
if(!require(devtools))
install.packages("devtools", repos = "http://cran.rstudio.com")
if(!require(thesisdown))
devtools::install_github("ismayc/thesisdown")
library(thesisdown)
```
# Random Test Output - *before* calling "library(huxtable)"
a table with pressure data
```{r pressure-table, echo=FALSE}
pressure
```
```{r echo=FALSE}
library(huxtable)
```
# Random Test Output - *after* calling "library(huxtable)"
a table with pressure data
```{r pressure-table2, echo=FALSE}
pressure
```
MWE summary:
knitting to HTML works always
knitting to PDF works only if there are no tables after "library(huxtable)", i.e. when the code chunk "pressure-table2" is not executed
UPDATE:
(1) If working with thesisdown, including the LaTex packages required by huxtable in the YAML-header as proposed by #dash2 works well.
(2) However, if working with huskydown, the issue unfortunately remains.
1. index.Rmd (thesisdown)
---
knit: "bookdown::render_book"
site: bookdown::bookdown_site
output:
thesisdown::thesis_pdf: default
# thesisdown::thesis_gitbook: default
header-includes:
- \usepackage{array}
- \usepackage{caption}
- \usepackage{graphicx}
- \usepackage{siunitx}
- \usepackage{colortbl}
- \usepackage{multirow}
- \usepackage{hhline}
- \usepackage{calc}
- \usepackage{tabularx}
- \usepackage{threeparttable}
- \usepackage{wrapfig}
---
...
2. index.Rmd (huskydown)
---
# UW thesis fields
title: "My thesis title - edit in index.Rmd"
author: "My Name"
year: "2017"
program: "My Department"
chair: "Name of my committee chair"
chairtitle: "Title of my chair"
signature1: "person 1"
signature2: "person 2"
signature3: "person 3"
abstract: |
"Here is my abstract"
acknowledgments: |
"My acknowledgments"
dedication: |
"My dedication"
knit: "bookdown::render_book"
site: bookdown::bookdown_site
output:
huskydown::thesis_pdf:
latex_engine: xelatex
bibliography: bib/thesis.bib
csl: csl/apa.csl
lot: true
lof: true
header-includes:
- \usepackage{tikz}
- \usepackage{array}
- \usepackage{caption}
- \usepackage{graphicx}
- \usepackage{siunitx}
- \usepackage{colortbl}
- \usepackage{multirow}
- \usepackage{hhline}
- \usepackage{calc}
- \usepackage{tabularx}
- \usepackage{threeparttable}
- \usepackage{wrapfig}
---
```{r include_packages, include = FALSE}
# This chunk ensures that the huskydown package is
# installed and loaded. This huskydown package includes
# the template files for the thesis.
if(!require(devtools))
install.packages("devtools", repos = "http://cran.rstudio.com")
if(!require(huskydown))
devtools::install_github("benmarwick/huskydown")
library(huskydown)
```
# Random Test Output - *before* calling "library(huxtable)"
a table with pressure data
```{r pressure-table, echo=FALSE}
pressure
```
```{r echo=FALSE}
library(huxtable)
```
# Random Test Output - *after* calling "library(huxtable)"
a table with pressure data
```{r pressure-table2, echo=FALSE}
pressure
```
Despite loading LaTex packages, knitting the index.Rmd for huskydown again throws the error:
! LaTeX Error: Environment threeparttable undefined.
Are any LaTex packages loaded with header-includes potentially ignored by huskydown?
Solution as recommended by #dash2: include LaTex packages manually
"LaTex packages loaded with header-includes ignored by huskydown?" - it seems that this presumption is actually the case.
Hence, the LaTex packages can not be included in the YAML header of the index.Rmd file.
The huskydown thesis template includes the file "template.tex" which defines the documentclass and sources several LaTex packages.
Manually adding all LaTex packages required by huxtable to this file solves the issue:
%-------------------------------
% Huxtable
%-------------------------------
% load LaTex packages needed for huxtable
\usepackage{array}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{colortbl}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{calc}
\usepackage{tabularx}
\usepackage{tabulary}
\usepackage{threeparttable}
\usepackage{wrapfig}
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}
I'm using Sweave to make a report in R-Studio, and I have the problem, that my teacher will only accept reports, where the code is placed in an Appendix. This means that I need to control the position of the chunk outputs (graphs).
Is this possible in Sweave?
Regards,
Jens
This will return everything in your code. Using the \usepackage{fancyvrb} and the \VerbatimInput{test.Rnw} assuming that your file is named test.Rnw
\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<my_code_chunk>>=
2+2
#
\section{Appendix}
\VerbatimInput{test.Rnw}
\end{document}
Here is another example
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<my_code_chunk>>=
2+2
#
\section{Appendix}
<<>>=
<<my_code_chunk>>
#
\end{document}