Reputation: 113
I have been trying to use "ragged2e" for text justification in a papaja-generated document with the method that has been proposed here:
https://stackoverflow.com/a/50042106
However, when I try to knit this:
---
title : "My title"
shorttitle : "Title"
author:
- name : "Raphaël Lorenz-de Laigue"
affiliation : "1"
corresponding : yes # Define only one corresponding author
address : "Postal address"
email : "[email protected]"
affiliation:
- id : "1"
institution : "Humboldt-Universität zu Berlin"
abstract: This is my abstract.
keywords : "keywords"
wordcount : "X"
floatsintext : no
figurelist : no
tablelist : no
footnotelist : no
linenumbers : no
mask : no
draft : no
figsintext : yes
header-includes:
- \usepackage[document]{ragged2e}
documentclass : "apa6"
classoption : "man"
output:
papaja::apa6_pdf:
latex_engine: xelatex
fig_caption: yes
---
```{r, include=FALSE}
options(tinytex.verbose = TRUE)
```
\justify
# Intro
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Commodo quis imperdiet massa tincidunt. Magna fermentum iaculis eu non diam phasellus vestibulum lorem. Ultricies integer quis auctor elit sed vulputate mi. Ligula ullamcorper malesuada proin libero nunc. Viverra justo nec ultrices dui sapien. Quisque egestas diam in arcu cursus euismod quis viverra. Suspendisse potenti nullam ac tortor vitae purus faucibus. Massa sapien faucibus et molestie ac. Volutpat commodo sed egestas egestas fringilla phasellus. Nibh cras pulvinar mattis nunc sed blandit libero volutpat. Ullamcorper morbi tincidunt ornare massa eget egestas purus viverra. Eu facilisis sed odio morbi quis. In aliquam sem fringilla ut morbi tincidunt augue. Dictumst quisque sagittis purus sit amet volutpat consequat mauris. Nec feugiat nisl pretium fusce. Sed euismod nisi porta lorem mollis aliquam ut porttitor. Ut enim blandit volutpat maecenas volutpat. Consectetur lorem donec massa sapien. Urna neque viverra justo nec.
I get the following error message:
I was unable to find any missing LaTeX packages from the error log not_justified.log.
! Improper \prevdepth.
\newpage ...everypar {}\fi \par \ifdim \prevdepth
>\z@ \vskip -\ifdim \prevd...
l.190 \end{document}
Error: LaTeX failed to compile not_justified.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See not_justified.log for more info.
In addition: Warning message:
In readLines(con, encoding = "bytes") :
incomplete final line found on 'justified.Rmd'
Execution halted
I have tried updating R and LaTeX packages, reinstalled tinytex as indicated here: https://yihui.org/tinytex/r/#debugging
The code includes the "tinytex.verbose" option as you can see above.
Best,
R.
Edit:
This is the content from the intermediate .tex file
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
man,floatsintext]{apa6}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={My title},
pdfauthor={Raphaël Lorenz-de Laigue1},
pdflang={en-EN},
pdfkeywords={keywords},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
% Make \paragraph and \subparagraph free-standing
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
\ifLuaTeX
\usepackage[bidi=basic]{babel}
\else
\usepackage[bidi=default]{babel}
\fi
\babelprovide[main,import]{english}
% get rid of language-specific shorthands (see #6817):
\let\LanguageShortHands\languageshorthands
\def\languageshorthands#1{}
% Manuscript styling
\usepackage{upgreek}
\captionsetup{font=singlespacing,justification=justified}
% Table formatting
\usepackage{longtable}
\usepackage{lscape}
% \usepackage[counterclockwise]{rotating} % Landscape page setup for large tables
\usepackage{multirow} % Table styling
\usepackage{tabularx} % Control Column width
\usepackage[flushleft]{threeparttable} % Allows for three part tables with a specified notes section
\usepackage{threeparttablex} % Lets threeparttable work with longtable
% Create new environments so endfloat can handle them
% \newenvironment{ltable}
% {\begin{landscape}\centering\begin{threeparttable}}
% {\end{threeparttable}\end{landscape}}
\newenvironment{lltable}{\begin{landscape}\centering\begin{ThreePartTable}}{\end{ThreePartTable}\end{landscape}}
% Enables adjusting longtable caption width to table width
% Solution found at http://golatex.de/longtable-mit-caption-so-breit-wie-die-tabelle-t15767.html
\makeatletter
\newcommand\LastLTentrywidth{1em}
\newlength\longtablewidth
\setlength{\longtablewidth}{1in}
\newcommand{\getlongtablewidth}{\begingroup \ifcsname LT@\roman{LT@tables}\endcsname \global\longtablewidth=0pt \renewcommand{\LT@entry}[2]{\global\advance\longtablewidth by ##2\relax\gdef\LastLTentrywidth{##2}}\@nameuse{LT@\roman{LT@tables}} \fi \endgroup}
% \setlength{\parindent}{0.5in}
% \setlength{\parskip}{0pt plus 0pt minus 0pt}
% Overwrite redefinition of paragraph and subparagraph by the default LaTeX template
% See https://github.com/crsh/papaja/issues/292
\makeatletter
\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\parindent}%
{0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
{-1em}%
{\normalfont\normalsize\bfseries\itshape\typesectitle}}
\renewcommand{\subparagraph}[1]{\@startsection{subparagraph}{5}{1em}%
{0\baselineskip \@plus 0.2ex \@minus 0.2ex}%
{-\z@\relax}%
{\normalfont\normalsize\itshape\hspace{\parindent}{#1}\textit{\addperi}}{\relax}}
\makeatother
% \usepackage{etoolbox}
\makeatletter
\patchcmd{\HyOrg@maketitle}
{\section{\normalfont\normalsize\abstractname}}
{\section*{\normalfont\normalsize\abstractname}}
{}{\typeout{Failed to patch abstract.}}
\patchcmd{\HyOrg@maketitle}
{\section{\protect\normalfont{\@title}}}
{\section*{\protect\normalfont{\@title}}}
{}{\typeout{Failed to patch title.}}
\makeatother
\usepackage{xpatch}
\makeatletter
\xapptocmd\appendix
{\xapptocmd\section
{\addcontentsline{toc}{section}{\appendixname\ifoneappendix\else~\theappendix\fi\\: #1}}
{}{\InnerPatchFailed}%
}
{}{\PatchFailed}
\keywords{keywords\newline\indent Word count: X}
\DeclareDelayedFloatFlavor{ThreePartTable}{table}
\DeclareDelayedFloatFlavor{lltable}{table}
\DeclareDelayedFloatFlavor*{longtable}{table}
\makeatletter
\renewcommand{\efloat@iwrite}[1]{\immediate\expandafter\protected@write\csname efloat@post#1\endcsname{}}
\makeatother
\usepackage{csquotes}
\usepackage[document]{ragged2e}
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\title{My title}
\author{Raphaël Lorenz-de Laigue\textsuperscript{1}}
\date{}
\shorttitle{Title}
\authornote{
Correspondence concerning this article should be addressed to Raphaël Lorenz-de Laigue, Postal address. E-mail: \href{mailto:[email protected]}{\nolinkurl{[email protected]}}
}
\affiliation{\vspace{0.5cm}\textsuperscript{1} Humboldt-Universität zu Berlin}
\abstract{%
This is my abstract.
}
\begin{document}
\maketitle
\justify
\hypertarget{intro}{%
\section{Intro}\label{intro}}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Commodo quis imperdiet massa tincidunt. Magna fermentum iaculis eu non diam phasellus vestibulum lorem. Ultricies integer quis auctor elit sed vulputate mi. Ligula ullamcorper malesuada proin libero nunc. Viverra justo nec ultrices dui sapien. Quisque egestas diam in arcu cursus euismod quis viverra. Suspendisse potenti nullam ac tortor vitae purus faucibus. Massa sapien faucibus et molestie ac. Volutpat commodo sed egestas egestas fringilla phasellus. Nibh cras pulvinar mattis nunc sed blandit libero volutpat. Ullamcorper morbi tincidunt ornare massa eget egestas purus viverra. Eu facilisis sed odio morbi quis. In aliquam sem fringilla ut morbi tincidunt augue. Dictumst quisque sagittis purus sit amet volutpat consequat mauris. Nec feugiat nisl pretium fusce. Sed euismod nisi porta lorem mollis aliquam ut porttitor. Ut enim blandit volutpat maecenas volutpat. Consectetur lorem donec massa sapien. Urna neque viverra justo nec.
\end{document}
Upvotes: 2
Views: 360
Reputation: 38748
The justify
is not an macro, but an environment. This environment is meant to be used as \begin{justify} ... \end{justify}
.
In your case, an environment is probably not desired if you still want to use markdown within it. So you can use the macro \justifying
instead:
---
title : "My title"
shorttitle : "Title"
author:
- name : "Raphaël Lorenz-de Laigue"
affiliation : "1"
corresponding : yes # Define only one corresponding author
address : "Postal address"
email : "[email protected]"
affiliation:
- id : "1"
institution : "Humboldt-Universität zu Berlin"
abstract: This is my abstract.
keywords : "keywords"
wordcount : "X"
floatsintext : no
figurelist : no
tablelist : no
footnotelist : no
linenumbers : no
mask : no
draft : no
figsintext : yes
header-includes:
- \usepackage[document]{ragged2e}
documentclass : "apa6"
classoption : "man"
output:
papaja::apa6_pdf:
latex_engine: xelatex
fig_caption: yes
---
```{r, include=FALSE}
options(tinytex.verbose = TRUE)
```
\justifying
# Intro
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Commodo quis imperdiet massa tincidunt. Magna fermentum iaculis eu non diam phasellus vestibulum lorem. Ultricies integer quis auctor elit sed vulputate mi. Ligula ullamcorper malesuada proin libero nunc. Viverra justo nec ultrices dui sapien. Quisque egestas diam in arcu cursus euismod quis viverra. Suspendisse potenti nullam ac tortor vitae purus faucibus. Massa sapien faucibus et molestie ac. Volutpat commodo sed egestas egestas fringilla phasellus. Nibh cras pulvinar mattis nunc sed blandit libero volutpat. Ullamcorper morbi tincidunt ornare massa eget egestas purus viverra. Eu facilisis sed odio morbi quis. In aliquam sem fringilla ut morbi tincidunt augue. Dictumst quisque sagittis purus sit amet volutpat consequat mauris. Nec feugiat nisl pretium fusce. Sed euismod nisi porta lorem mollis aliquam ut porttitor. Ut enim blandit volutpat maecenas volutpat. Consectetur lorem donec massa sapien. Urna neque viverra justo nec.
Upvotes: 2