0

Consider the following example:

\documentclass[oneside,article]{memoir}
\usepackage{listings}
\usepackage[lining]{ebgaramond}
\usepackage[cmintegrals,cmbraces]{newtxmath}
\usepackage{ebgaramond-maths}
\usepackage{fontspec}
\usepackage{color}

\lstnewenvironment{Rlisting} { 
  \vskip 1\baselineskip
  \noindent   
  \checkoddpage% 
  \ifoddpage%
     \hspace*{-3em}%
  \else%
     \hspace*{-3em}%
  \fi%
  \begin{minipage}{1\textwidth + 6em}
  \lstset{ language=R, 
           basicstyle=\footnotesize\ttfamily, 
           frame=single,
           breaklines=true,
           postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space}, 
         }
} { 
    \end{minipage}
    \vskip 1\baselineskip
}

\begin{document}
\begin{Rlisting}
> library(xlsx)
Loading required package: rJava
Loading required package: xlsxjars
\end{Rlisting}

\end{document}

As I try to compile this, my compiler just get's totally stuck in some really strange mode:

$ latexmk -pdf -pvc -lualatex test.tex
Latexmk: This is Latexmk, John Collins, 19 Jan. 2017, version: 4.52c.
Viewing pdf
Latexmk: applying rule 'lualatex'...
Rule 'lualatex': File changes, etc:
   Non-existent destination files:
      'test.pdf'
------------
Run number 1 of rule 'lualatex'
------------
------------
Running 'lualatex  -recorder  "test.tex"'
------------
This is LuaTeX, Version 1.0.4 (TeX Live 2017) 

[...]

LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <5.5> not available
(Font)              size <5> substituted on input line 32.

(load luc: /Users/jonathan/Library/texlive/2017/texmf-var/luatex-cache/generic/
fonts/otl/lmmonolt10-bold.luc))
*

I seem to be stuck in a strange mode. I can't even access the normal help things but first have to break out using Ctrl + C and Enter. Can someone tell me what is going on here and how I can fix it?

jonalv
  • 11,466
  • 4
    Possible duplicate of Set horizontal width on custom listings environment. The problem is the minipage inside the lstnewenvironment, you can set the width for the listing using \lstset{linewidth=<length>}. – Marijn May 24 '19 at 09:44
  • @Marijn: But that doesn't do the same thing. It places the listing oriented to the left margin of the page I want it centered and going out into the margins on both sides... – jonalv May 24 '19 at 11:06
  • I see, that was not immediately clear from the question - in that case you can do something like \BeforeBeginEnvironment{Rlisting}{\begin{adjustwidth}{-1cm}{-1cm}}\AfterEndEnvironment{Rlisting}{\end{adjustwidth}} using the etoolbox and changepage packages. – Marijn May 24 '19 at 11:42

0 Answers0