emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Forcing line breaks in src (monospace) examples
@ 2015-06-14 14:44 Peter Davis
  2015-06-14 14:51 ` Peter Davis
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Davis @ 2015-06-14 14:44 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1238 bytes --]

I'm writing a document which includes several example commands, which 
I've wrapped in #+BEGIN_SRC/#+END_SRC.

In LaTeX/PDF export, these come out in Courier, as I hoped, but they run 
off the right edge of the page. For example:

#+BEGIN_SRC curl
curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..." 
"http://blah.blah.blah.com/v1/REST_API_STUFF/..."
#+END_SRC

Years ago, someone on a TeX mailing list offered some code to force line 
breaking in \tt{...} code, with a \triangleright at the right margin to 
show the line overflowed. I think this was all it took:

% Define obj
{\catcode`\_=13\gdef_{{\tt\char`\_}%
\discretionary{\rlap{$\triangleright$}}{\llap{$\triangleright$}}{}}}
\def\obj{\bgroup\catcode`\_=13\hyphenpenalty=10000\relax\sf\sc\endobj}
\def\endobj#1{#1\egroup}

However, I'm not enough of a TeX wiz to know how to make this work with 
org-mode, or even if I can. I tried replacing the above with:

#+BEGIN_LaTeX
curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..." 
"http://blah.blah.blah.com/v1/REST_API_STUFF/..."
#+END_LaTeX

But (apart from the need to quote the backslashes, etc.), this didn't 
seem to do what I wanted.

Any suggestions on how to force line breaks?

Thank you!
-pd


[-- Attachment #2: Type: text/html, Size: 4094 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Forcing line breaks in src (monospace) examples
  2015-06-14 14:44 Forcing line breaks in src (monospace) examples Peter Davis
@ 2015-06-14 14:51 ` Peter Davis
  2015-06-14 15:36   ` Robert Klein
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Davis @ 2015-06-14 14:51 UTC (permalink / raw)
  To: emacs-orgmode



On 6/14/15 10:44 AM, Peter Davis wrote:
> #+BEGIN_LaTeX
> curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..." 
> "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
> #+END_LaTeX
Sorry, that should be:


#+BEGIN_LaTeX
\tt{curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..." 
"http://blah.blah.blah.com/v1/REST_API_STUFF/..."}
#+END_LaTeX

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Forcing line breaks in src (monospace) examples
  2015-06-14 14:51 ` Peter Davis
@ 2015-06-14 15:36   ` Robert Klein
  2015-06-14 15:53     ` Peter Davis
  0 siblings, 1 reply; 12+ messages in thread
From: Robert Klein @ 2015-06-14 15:36 UTC (permalink / raw)
  To: Peter Davis; +Cc: emacs-orgmode

Hi,

On Sun, 14 Jun 2015 10:51:59 -0400
Peter Davis <pfd@pfdstudio.com> wrote:

> 
> 
> On 6/14/15 10:44 AM, Peter Davis wrote:
> > #+BEGIN_LaTeX
> > curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..." 
> > "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
> > #+END_LaTeX
> Sorry, that should be:
> 
> 
> #+BEGIN_LaTeX
> \tt{curl -v -X GET -H "Authorization:...\",   \"access_token\":
> \"..." "http://blah.blah.blah.com/v1/REST_API_STUFF/..."}
> #+END_LaTeX
> 
> 


This will do the job:

#+LaTeX_HEADER: \usepackage{xcolor}
#+LaTeX_HEADER: \lstset{
#+LaTeX_HEADER:     basicstyle=\ttfamily,
#+LaTeX_HEADER:     breaklines=true,
#+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
#+LaTeX_HEADER:     columns=fullflexible,
#+LaTeX_HEADER:     keepspaces=true
#+LaTeX_HEADER: }


#+begin_src sh
  curl -v -X GET -H "Authorization:...",   "access_token": "..."
  "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
#+end_src


Note I use a `sh' source block, not `curl' and not a LaTeX block.  So
you'll also be able to publish to HTML and someone using the document
can copy and past the command to her/his command line.

The `prebreak' setting for some reasons needs some kind of box or the
LaTeX process croaks.

Also nice, I got this from
tex.stackexchange.com/questions/116534/lstlisting-line-wrapping is
this postbreak setting for lstlistings (needs the xcolor package above):

postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},


Best regards
Robert

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Forcing line breaks in src (monospace) examples
  2015-06-14 15:36   ` Robert Klein
@ 2015-06-14 15:53     ` Peter Davis
  2015-06-14 16:11       ` Robert Klein
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Davis @ 2015-06-14 15:53 UTC (permalink / raw)
  To: emacs-orgmode

Robert Klein <RoKlein@roklein.de> writes:

> Hi,
>
> On Sun, 14 Jun 2015 10:51:59 -0400
> Peter Davis <pfd@pfdstudio.com> wrote:
>
>> 
>> 
>> On 6/14/15 10:44 AM, Peter Davis wrote:
>> > #+BEGIN_LaTeX
>> > curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..." 
>> > "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
>> > #+END_LaTeX
>> Sorry, that should be:
>> 
>> 
>> #+BEGIN_LaTeX
>> \tt{curl -v -X GET -H "Authorization:...\",   \"access_token\":
>> \"..." "http://blah.blah.blah.com/v1/REST_API_STUFF/..."}
>> #+END_LaTeX
>> 
>> 
>
>
> This will do the job:
>
> #+LaTeX_HEADER: \usepackage{xcolor}
> #+LaTeX_HEADER: \lstset{
> #+LaTeX_HEADER:     basicstyle=\ttfamily,
> #+LaTeX_HEADER:     breaklines=true,
> #+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
> #+LaTeX_HEADER:     columns=fullflexible,
> #+LaTeX_HEADER:     keepspaces=true
> #+LaTeX_HEADER: }
>
>
> #+begin_src sh
>   curl -v -X GET -H "Authorization:...",   "access_token": "..."
>   "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
> #+end_src
>
>
> Note I use a `sh' source block, not `curl' and not a LaTeX block.  So
> you'll also be able to publish to HTML and someone using the document
> can copy and past the command to her/his command line.
>
> The `prebreak' setting for some reasons needs some kind of box or the
> LaTeX process croaks.
>
> Also nice, I got this from
> tex.stackexchange.com/questions/116534/lstlisting-line-wrapping is
> this postbreak setting for lstlistings (needs the xcolor package above):
>
> postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
>

Thanks, Robert. This looks very promising, but it doesn't seem to work
for me. Here's my sample document:

------ cut here ------
#+LaTeX_HEADER: \usepackage{xcolor}
#+LaTeX_HEADER: \lstset{
#+LaTeX_HEADER:     basicstyle=\ttfamily,
#+LaTeX_HEADER:     breaklines=true,
#+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
#+LaTeX_HEADER:     postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
#+LaTeX_HEADER:     columns=fullflexible,
#+LaTeX_HEADER:     keepspaces=true
#+LaTeX_HEADER: }
#+LaTeX_CLASS_OPTIONS: [article,letterpaper,times,12pt,listings-bw,microtype]
#+author: Peter Davis
#+title: Hello, Test Document

#+BEGIN_SRC sh
curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..." "http://blah.blah.blah.com/v1/blahblahblah/..."
#+END_SRC
------ cut here ------

Thank you!

-pd

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Forcing line breaks in src (monospace) examples
  2015-06-14 15:53     ` Peter Davis
@ 2015-06-14 16:11       ` Robert Klein
  2015-06-14 16:23         ` Peter Davis
  0 siblings, 1 reply; 12+ messages in thread
From: Robert Klein @ 2015-06-14 16:11 UTC (permalink / raw)
  To: Peter Davis; +Cc: emacs-orgmode


Hi Peter,

sorry, I have 

(add-to-list 'org-latex-packages-alist '("" "listingsutf8"))

in my .emacs  (utf8 version of listings so I can use umlauts).


You can also simply put

#+LaTeX_HEADER: \usepackage{listings}

to the top of the file.


(PS: you won't need the xcolor package unless you want your triangle
e.g. in red...)

Best regards
Robert


On Sun, 14 Jun 2015 11:53:22 -0400
Peter Davis <pfd@pfdstudio.com> wrote:

> Robert Klein <RoKlein@roklein.de> writes:
> 
> > Hi,
> >
> > On Sun, 14 Jun 2015 10:51:59 -0400
> > Peter Davis <pfd@pfdstudio.com> wrote:
> >
> >> 
> >> 
> >> On 6/14/15 10:44 AM, Peter Davis wrote:
> >> > #+BEGIN_LaTeX
> >> > curl -v -X GET -H "Authorization:...\",   \"access_token\":
> >> > \"..." "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
> >> > #+END_LaTeX
> >> Sorry, that should be:
> >> 
> >> 
> >> #+BEGIN_LaTeX
> >> \tt{curl -v -X GET -H "Authorization:...\",   \"access_token\":
> >> \"..." "http://blah.blah.blah.com/v1/REST_API_STUFF/..."}
> >> #+END_LaTeX
> >> 
> >> 
> >
> >
> > This will do the job:
> >
> > #+LaTeX_HEADER: \usepackage{xcolor}
> > #+LaTeX_HEADER: \lstset{
> > #+LaTeX_HEADER:     basicstyle=\ttfamily,
> > #+LaTeX_HEADER:     breaklines=true,
> > #+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
> > #+LaTeX_HEADER:     columns=fullflexible,
> > #+LaTeX_HEADER:     keepspaces=true
> > #+LaTeX_HEADER: }
> >
> >
> > #+begin_src sh
> >   curl -v -X GET -H "Authorization:...",   "access_token": "..."
> >   "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
> > #+end_src
> >
> >
> > Note I use a `sh' source block, not `curl' and not a LaTeX block.
> > So you'll also be able to publish to HTML and someone using the
> > document can copy and past the command to her/his command line.
> >
> > The `prebreak' setting for some reasons needs some kind of box or
> > the LaTeX process croaks.
> >
> > Also nice, I got this from
> > tex.stackexchange.com/questions/116534/lstlisting-line-wrapping is
> > this postbreak setting for lstlistings (needs the xcolor package
> > above):
> >
> > postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
> >
> 
> Thanks, Robert. This looks very promising, but it doesn't seem to work
> for me. Here's my sample document:
> 
> ------ cut here ------
> #+LaTeX_HEADER: \usepackage{xcolor}
> #+LaTeX_HEADER: \lstset{
> #+LaTeX_HEADER:     basicstyle=\ttfamily,
> #+LaTeX_HEADER:     breaklines=true,
> #+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
> #+LaTeX_HEADER:
> postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
> #+LaTeX_HEADER:     columns=fullflexible, #+LaTeX_HEADER:
> keepspaces=true #+LaTeX_HEADER: }
> #+LaTeX_CLASS_OPTIONS:
> [article,letterpaper,times,12pt,listings-bw,microtype] #+author:
> Peter Davis #+title: Hello, Test Document
> 
> #+BEGIN_SRC sh
> curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..."
> "http://blah.blah.blah.com/v1/blahblahblah/..." #+END_SRC
> ------ cut here ------
> 
> Thank you!
> 
> -pd
> 
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Forcing line breaks in src (monospace) examples
  2015-06-14 16:11       ` Robert Klein
@ 2015-06-14 16:23         ` Peter Davis
  2015-06-14 16:36           ` Peter Davis
  2015-06-14 16:38           ` Robert Klein
  0 siblings, 2 replies; 12+ messages in thread
From: Peter Davis @ 2015-06-14 16:23 UTC (permalink / raw)
  To: Robert Klein; +Cc: emacs-orgmode


Hi, Robert,

That helps (it gets rid of the extra first page), but I'm still not
getting the line to wrap.

Thanks,
-pd


Robert Klein <RoKlein@roklein.de> writes:

> Hi Peter,
>
> sorry, I have 
>
> (add-to-list 'org-latex-packages-alist '("" "listingsutf8"))
>
> in my .emacs  (utf8 version of listings so I can use umlauts).
>
>
> You can also simply put
>
> #+LaTeX_HEADER: \usepackage{listings}
>
> to the top of the file.
>
>
> (PS: you won't need the xcolor package unless you want your triangle
> e.g. in red...)
>
> Best regards
> Robert
>
>
> On Sun, 14 Jun 2015 11:53:22 -0400
> Peter Davis <pfd@pfdstudio.com> wrote:
>
>> Robert Klein <RoKlein@roklein.de> writes:
>> 
>> > Hi,
>> >
>> > On Sun, 14 Jun 2015 10:51:59 -0400
>> > Peter Davis <pfd@pfdstudio.com> wrote:
>> >
>> >> 
>> >> 
>> >> On 6/14/15 10:44 AM, Peter Davis wrote:
>> >> > #+BEGIN_LaTeX
>> >> > curl -v -X GET -H "Authorization:...\",   \"access_token\":
>> >> > \"..." "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
>> >> > #+END_LaTeX
>> >> Sorry, that should be:
>> >> 
>> >> 
>> >> #+BEGIN_LaTeX
>> >> \tt{curl -v -X GET -H "Authorization:...\",   \"access_token\":
>> >> \"..." "http://blah.blah.blah.com/v1/REST_API_STUFF/..."}
>> >> #+END_LaTeX
>> >> 
>> >> 
>> >
>> >
>> > This will do the job:
>> >
>> > #+LaTeX_HEADER: \usepackage{xcolor}
>> > #+LaTeX_HEADER: \lstset{
>> > #+LaTeX_HEADER:     basicstyle=\ttfamily,
>> > #+LaTeX_HEADER:     breaklines=true,
>> > #+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
>> > #+LaTeX_HEADER:     columns=fullflexible,
>> > #+LaTeX_HEADER:     keepspaces=true
>> > #+LaTeX_HEADER: }
>> >
>> >
>> > #+begin_src sh
>> >   curl -v -X GET -H "Authorization:...",   "access_token": "..."
>> >   "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
>> > #+end_src
>> >
>> >
>> > Note I use a `sh' source block, not `curl' and not a LaTeX block.
>> > So you'll also be able to publish to HTML and someone using the
>> > document can copy and past the command to her/his command line.
>> >
>> > The `prebreak' setting for some reasons needs some kind of box or
>> > the LaTeX process croaks.
>> >
>> > Also nice, I got this from
>> > tex.stackexchange.com/questions/116534/lstlisting-line-wrapping is
>> > this postbreak setting for lstlistings (needs the xcolor package
>> > above):
>> >
>> > postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
>> >
>> 
>> Thanks, Robert. This looks very promising, but it doesn't seem to work
>> for me. Here's my sample document:
>> 
>> ------ cut here ------
>> #+LaTeX_HEADER: \usepackage{xcolor}
>> #+LaTeX_HEADER: \lstset{
>> #+LaTeX_HEADER:     basicstyle=\ttfamily,
>> #+LaTeX_HEADER:     breaklines=true,
>> #+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
>> #+LaTeX_HEADER:
>> postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
>> #+LaTeX_HEADER:     columns=fullflexible, #+LaTeX_HEADER:
>> keepspaces=true #+LaTeX_HEADER: }
>> #+LaTeX_CLASS_OPTIONS:
>> [article,letterpaper,times,12pt,listings-bw,microtype] #+author:
>> Peter Davis #+title: Hello, Test Document
>> 
>> #+BEGIN_SRC sh
>> curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..."
>> "http://blah.blah.blah.com/v1/blahblahblah/..." #+END_SRC
>> ------ cut here ------
>> 
>> Thank you!
>> 
>> -pd
>> 
>> 
>> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Forcing line breaks in src (monospace) examples
  2015-06-14 16:23         ` Peter Davis
@ 2015-06-14 16:36           ` Peter Davis
  2015-06-14 16:38           ` Robert Klein
  1 sibling, 0 replies; 12+ messages in thread
From: Peter Davis @ 2015-06-14 16:36 UTC (permalink / raw)
  To: emacs-orgmode

FWIW, here's the tex generated from my current test:

% Created 2015-06-14 Sun 12:33
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\usepackage{listingsutf8}
\usepackage{listings}
\usepackage{xcolor}
\lstset{
basicstyle=\ttfamily,
breaklines=true,
prebreak=\mbox{\ensuremath{\color{red}\hookleftarrow}},
postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
columns=fullflexible,
keepspaces=true
}
\author{Peter Davis}
\date{\today}
\title{wraptest}
\hypersetup{
   pdfkeywords={},
   pdfsubject={},
   pdfcreator={Emacs 24.5.1 (Org mode 8.2.10)}}
\begin{document}

\maketitle
\setcounter{tocdepth}{0}
\tableofcontents

\begin{verbatim}
curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..." 
"http://sandbox.api.hmhco.com/v1/staffSectionAssociations/..."
\end{verbatim}
% Emacs 24.5.1 (Org mode 8.2.10)
\end{document}

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Forcing line breaks in src (monospace) examples
  2015-06-14 16:23         ` Peter Davis
  2015-06-14 16:36           ` Peter Davis
@ 2015-06-14 16:38           ` Robert Klein
  2015-06-14 17:01             ` Peter Davis
  1 sibling, 1 reply; 12+ messages in thread
From: Robert Klein @ 2015-06-14 16:38 UTC (permalink / raw)
  To: Peter Davis; +Cc: emacs-orgmode

Hi Peter,

hmm, yes, you have to tell org to use the listings package.

It works when I use this one-line .emacs:

(setq org-latex-listings t)


and your example file plus `#+LaTeX_HEADER: \usepackage{listings}':

--- snip ---
#+LaTeX_HEADER: \usepackage{listings}
#+LaTeX_HEADER: \usepackage{xcolor}
#+LaTeX_HEADER: \lstset{
#+LaTeX_HEADER:     basicstyle=\ttfamily,
#+LaTeX_HEADER:     breaklines=true,
#+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
#+LaTeX_HEADER:
     postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\$
#+LaTeX_HEADER:     columns=fullflexible,
#+LaTeX_HEADER:     keepspaces=true 
#+LaTeX_HEADER: }
#+LaTeX_CLASS_OPTIONS:
[article,letterpaper,times,12pt,listings-bw,microtype] 
#+author: Peter Davis 
#+title: Hello, Test Document

#+BEGIN_SRC
sh curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..."
"http://blah.blah.blah.com/v1/blahblahblah/..."
#+END_SRC                                                                       
--- snip ---

Sorry for the confusion.

Best regards
Robert




On Sun, 14 Jun 2015 12:23:06 -0400
Peter Davis <pfd@pfdstudio.com> wrote:

> 
> Hi, Robert,
> 
> That helps (it gets rid of the extra first page), but I'm still not
> getting the line to wrap.
> 
> Thanks,
> -pd
> 
> 
> Robert Klein <RoKlein@roklein.de> writes:
> 
> > Hi Peter,
> >
> > sorry, I have 
> >
> > (add-to-list 'org-latex-packages-alist '("" "listingsutf8"))
> >
> > in my .emacs  (utf8 version of listings so I can use umlauts).
> >
> >
> > You can also simply put
> >
> > #+LaTeX_HEADER: \usepackage{listings}
> >
> > to the top of the file.
> >
> >
> > (PS: you won't need the xcolor package unless you want your triangle
> > e.g. in red...)
> >
> > Best regards
> > Robert
> >
> >
> > On Sun, 14 Jun 2015 11:53:22 -0400
> > Peter Davis <pfd@pfdstudio.com> wrote:
> >
> >> Robert Klein <RoKlein@roklein.de> writes:
> >> 
> >> > Hi,
> >> >
> >> > On Sun, 14 Jun 2015 10:51:59 -0400
> >> > Peter Davis <pfd@pfdstudio.com> wrote:
> >> >
> >> >> 
> >> >> 
> >> >> On 6/14/15 10:44 AM, Peter Davis wrote:
> >> >> > #+BEGIN_LaTeX
> >> >> > curl -v -X GET -H "Authorization:...\",   \"access_token\":
> >> >> > \"..." "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
> >> >> > #+END_LaTeX
> >> >> Sorry, that should be:
> >> >> 
> >> >> 
> >> >> #+BEGIN_LaTeX
> >> >> \tt{curl -v -X GET -H "Authorization:...\",   \"access_token\":
> >> >> \"..." "http://blah.blah.blah.com/v1/REST_API_STUFF/..."}
> >> >> #+END_LaTeX
> >> >> 
> >> >> 
> >> >
> >> >
> >> > This will do the job:
> >> >
> >> > #+LaTeX_HEADER: \usepackage{xcolor}
> >> > #+LaTeX_HEADER: \lstset{
> >> > #+LaTeX_HEADER:     basicstyle=\ttfamily,
> >> > #+LaTeX_HEADER:     breaklines=true,
> >> > #+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
> >> > #+LaTeX_HEADER:     columns=fullflexible,
> >> > #+LaTeX_HEADER:     keepspaces=true
> >> > #+LaTeX_HEADER: }
> >> >
> >> >
> >> > #+begin_src sh
> >> >   curl -v -X GET -H "Authorization:...",   "access_token": "..."
> >> >   "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
> >> > #+end_src
> >> >
> >> >
> >> > Note I use a `sh' source block, not `curl' and not a LaTeX block.
> >> > So you'll also be able to publish to HTML and someone using the
> >> > document can copy and past the command to her/his command line.
> >> >
> >> > The `prebreak' setting for some reasons needs some kind of box or
> >> > the LaTeX process croaks.
> >> >
> >> > Also nice, I got this from
> >> > tex.stackexchange.com/questions/116534/lstlisting-line-wrapping
> >> > is this postbreak setting for lstlistings (needs the xcolor
> >> > package above):
> >> >
> >> > postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
> >> >
> >> 
> >> Thanks, Robert. This looks very promising, but it doesn't seem to
> >> work for me. Here's my sample document:
> >> 
> >> ------ cut here ------
> >> #+LaTeX_HEADER: \usepackage{xcolor}
> >> #+LaTeX_HEADER: \lstset{
> >> #+LaTeX_HEADER:     basicstyle=\ttfamily,
> >> #+LaTeX_HEADER:     breaklines=true,
> >> #+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
> >> #+LaTeX_HEADER:
> >> postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
> >> #+LaTeX_HEADER:     columns=fullflexible, #+LaTeX_HEADER:
> >> keepspaces=true #+LaTeX_HEADER: }
> >> #+LaTeX_CLASS_OPTIONS:
> >> [article,letterpaper,times,12pt,listings-bw,microtype] #+author:
> >> Peter Davis #+title: Hello, Test Document
> >> 
> >> #+BEGIN_SRC sh
> >> curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..."
> >> "http://blah.blah.blah.com/v1/blahblahblah/..." #+END_SRC
> >> ------ cut here ------
> >> 
> >> Thank you!
> >> 
> >> -pd
> >> 
> >> 
> >> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Forcing line breaks in src (monospace) examples
  2015-06-14 16:38           ` Robert Klein
@ 2015-06-14 17:01             ` Peter Davis
  2015-06-23 14:59               ` Peter Davis
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Davis @ 2015-06-14 17:01 UTC (permalink / raw)
  To: emacs-orgmode

Ah! I wound up adding this:

#+LaTeX_HEADER: 
\renewenvironment{verbatim}{\begin{lstlisting}}{\end{lstlisting}\ignorespacesafterend}


but your approach is cleaner.

Thanks!
-pd

On 6/14/15 12:38 PM, Robert Klein wrote:
> Hi Peter,
>
> hmm, yes, you have to tell org to use the listings package.
>
> It works when I use this one-line .emacs:
>
> (setq org-latex-listings t)
>
>
> and your example file plus `#+LaTeX_HEADER: \usepackage{listings}':
>
> --- snip ---
> #+LaTeX_HEADER: \usepackage{listings}
> #+LaTeX_HEADER: \usepackage{xcolor}
> #+LaTeX_HEADER: \lstset{
> #+LaTeX_HEADER:     basicstyle=\ttfamily,
> #+LaTeX_HEADER:     breaklines=true,
> #+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
> #+LaTeX_HEADER:
>       postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\$
> #+LaTeX_HEADER:     columns=fullflexible,
> #+LaTeX_HEADER:     keepspaces=true
> #+LaTeX_HEADER: }
> #+LaTeX_CLASS_OPTIONS:
> [article,letterpaper,times,12pt,listings-bw,microtype]
> #+author: Peter Davis
> #+title: Hello, Test Document
>
> #+BEGIN_SRC
> sh curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..."
> "http://blah.blah.blah.com/v1/blahblahblah/..."
> #+END_SRC
> --- snip ---
>
> Sorry for the confusion.
>
> Best regards
> Robert
>
>
>
>
> On Sun, 14 Jun 2015 12:23:06 -0400
> Peter Davis <pfd@pfdstudio.com> wrote:
>
>> Hi, Robert,
>>
>> That helps (it gets rid of the extra first page), but I'm still not
>> getting the line to wrap.
>>
>> Thanks,
>> -pd
>>
>>
>> Robert Klein <RoKlein@roklein.de> writes:
>>
>>> Hi Peter,
>>>
>>> sorry, I have
>>>
>>> (add-to-list 'org-latex-packages-alist '("" "listingsutf8"))
>>>
>>> in my .emacs  (utf8 version of listings so I can use umlauts).
>>>
>>>
>>> You can also simply put
>>>
>>> #+LaTeX_HEADER: \usepackage{listings}
>>>
>>> to the top of the file.
>>>
>>>
>>> (PS: you won't need the xcolor package unless you want your triangle
>>> e.g. in red...)
>>>
>>> Best regards
>>> Robert
>>>
>>>
>>> On Sun, 14 Jun 2015 11:53:22 -0400
>>> Peter Davis <pfd@pfdstudio.com> wrote:
>>>
>>>> Robert Klein <RoKlein@roklein.de> writes:
>>>>
>>>>> Hi,
>>>>>
>>>>> On Sun, 14 Jun 2015 10:51:59 -0400
>>>>> Peter Davis <pfd@pfdstudio.com> wrote:
>>>>>
>>>>>>
>>>>>> On 6/14/15 10:44 AM, Peter Davis wrote:
>>>>>>> #+BEGIN_LaTeX
>>>>>>> curl -v -X GET -H "Authorization:...\",   \"access_token\":
>>>>>>> \"..." "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
>>>>>>> #+END_LaTeX
>>>>>> Sorry, that should be:
>>>>>>
>>>>>>
>>>>>> #+BEGIN_LaTeX
>>>>>> \tt{curl -v -X GET -H "Authorization:...\",   \"access_token\":
>>>>>> \"..." "http://blah.blah.blah.com/v1/REST_API_STUFF/..."}
>>>>>> #+END_LaTeX
>>>>>>
>>>>>>
>>>>>
>>>>> This will do the job:
>>>>>
>>>>> #+LaTeX_HEADER: \usepackage{xcolor}
>>>>> #+LaTeX_HEADER: \lstset{
>>>>> #+LaTeX_HEADER:     basicstyle=\ttfamily,
>>>>> #+LaTeX_HEADER:     breaklines=true,
>>>>> #+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
>>>>> #+LaTeX_HEADER:     columns=fullflexible,
>>>>> #+LaTeX_HEADER:     keepspaces=true
>>>>> #+LaTeX_HEADER: }
>>>>>
>>>>>
>>>>> #+begin_src sh
>>>>>    curl -v -X GET -H "Authorization:...",   "access_token": "..."
>>>>>    "http://blah.blah.blah.com/v1/REST_API_STUFF/..."
>>>>> #+end_src
>>>>>
>>>>>
>>>>> Note I use a `sh' source block, not `curl' and not a LaTeX block.
>>>>> So you'll also be able to publish to HTML and someone using the
>>>>> document can copy and past the command to her/his command line.
>>>>>
>>>>> The `prebreak' setting for some reasons needs some kind of box or
>>>>> the LaTeX process croaks.
>>>>>
>>>>> Also nice, I got this from
>>>>> tex.stackexchange.com/questions/116534/lstlisting-line-wrapping
>>>>> is this postbreak setting for lstlistings (needs the xcolor
>>>>> package above):
>>>>>
>>>>> postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
>>>>>
>>>> Thanks, Robert. This looks very promising, but it doesn't seem to
>>>> work for me. Here's my sample document:
>>>>
>>>> ------ cut here ------
>>>> #+LaTeX_HEADER: \usepackage{xcolor}
>>>> #+LaTeX_HEADER: \lstset{
>>>> #+LaTeX_HEADER:     basicstyle=\ttfamily,
>>>> #+LaTeX_HEADER:     breaklines=true,
>>>> #+LaTeX_HEADER:     prebreak=\mbox{\ensuremath{\triangleright}},
>>>> #+LaTeX_HEADER:
>>>> postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}},
>>>> #+LaTeX_HEADER:     columns=fullflexible, #+LaTeX_HEADER:
>>>> keepspaces=true #+LaTeX_HEADER: }
>>>> #+LaTeX_CLASS_OPTIONS:
>>>> [article,letterpaper,times,12pt,listings-bw,microtype] #+author:
>>>> Peter Davis #+title: Hello, Test Document
>>>>
>>>> #+BEGIN_SRC sh
>>>> curl -v -X GET -H "Authorization:...\",   \"access_token\": \"..."
>>>> "http://blah.blah.blah.com/v1/blahblahblah/..." #+END_SRC
>>>> ------ cut here ------
>>>>
>>>> Thank you!
>>>>
>>>> -pd
>>>>
>>>>
>>>>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Forcing line breaks in src (monospace) examples
  2015-06-14 17:01             ` Peter Davis
@ 2015-06-23 14:59               ` Peter Davis
  2015-06-23 15:11                 ` Kaushal
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Davis @ 2015-06-23 14:59 UTC (permalink / raw)
  To: emacs-orgmode


So getting line breaks in exported LaTeX/PDF src examples is now working 
beautifully.

Is there any way to do this in exported HTML?

Thank you,
-pd

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Forcing line breaks in src (monospace) examples
  2015-06-23 14:59               ` Peter Davis
@ 2015-06-23 15:11                 ` Kaushal
  2015-06-23 15:30                   ` Peter Davis
  0 siblings, 1 reply; 12+ messages in thread
From: Kaushal @ 2015-06-23 15:11 UTC (permalink / raw)
  To: Peter Davis, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1115 bytes --]

On the topic of exporting auto-wrapped lines in source code blocks to
.tex/.pdf:

If you use minted instead of listings, the latest minted 2.0 (probably not
yet on tex-live) latex package does line wrapping in the source code blocks
very elegantly.

https://github.com/gpoore/minted

            (setq org-latex-listings 'minted)

            (setq org-latex-minted-options
                  '(("linenos")
                    ("numbersep"   "5pt")
                    ("frame"       "none") ; box frame is created by the
mdframed package
                    ("framesep"    "2mm")
                    ;; ("fontfamily"  "zi4") ; required only when using
pdflatex
                                        ; instead of xelatex
                    ;; minted 2.0 specific features
                    ("breaklines") ; line wrapping within code blocks
                    ))




On Tue, Jun 23, 2015 at 10:59 AM Peter Davis <pfd@pfdstudio.com> wrote:

>
> So getting line breaks in exported LaTeX/PDF src examples is now working
> beautifully.
>
> Is there any way to do this in exported HTML?
>
> Thank you,
> -pd
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 1907 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Forcing line breaks in src (monospace) examples
  2015-06-23 15:11                 ` Kaushal
@ 2015-06-23 15:30                   ` Peter Davis
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Davis @ 2015-06-23 15:30 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 836 bytes --]

Thanks!

I think for my purposes with HTML, it would be sufficient to replace 
<pre>...</pre> with <tt>...</tt>. Is there a way to get org to do that 
on export, or do I have to keep editing the HTML output?

Thank you.

-pd


On 6/23/15 11:11 AM, Kaushal wrote:
> On the topic of exporting auto-wrapped lines in source code blocks to 
> .tex/.pdf:
>
> If you use minted instead of listings, the latest minted 2.0 (probably 
> not yet on tex-live) latex package does line wrapping in the source 
> code blocks very elegantly.
...
>
>
> On Tue, Jun 23, 2015 at 10:59 AM Peter Davis <pfd@pfdstudio.com 
> <mailto:pfd@pfdstudio.com>> wrote:
>
>
>     So getting line breaks in exported LaTeX/PDF src examples is now
>     working
>     beautifully.
>
>     Is there any way to do this in exported HTML?
>
>     Thank you,
>     -pd
>
>
>


[-- Attachment #2: Type: text/html, Size: 1997 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-06-23 15:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-14 14:44 Forcing line breaks in src (monospace) examples Peter Davis
2015-06-14 14:51 ` Peter Davis
2015-06-14 15:36   ` Robert Klein
2015-06-14 15:53     ` Peter Davis
2015-06-14 16:11       ` Robert Klein
2015-06-14 16:23         ` Peter Davis
2015-06-14 16:36           ` Peter Davis
2015-06-14 16:38           ` Robert Klein
2015-06-14 17:01             ` Peter Davis
2015-06-23 14:59               ` Peter Davis
2015-06-23 15:11                 ` Kaushal
2015-06-23 15:30                   ` Peter Davis

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).