emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Code blocks and quotes export style
@ 2022-03-13 10:54 Sébastien Gendre
  2022-03-13 16:06 ` Kaushal Modi
  2022-03-13 18:55 ` Barton, Mark
  0 siblings, 2 replies; 8+ messages in thread
From: Sébastien Gendre @ 2022-03-13 10:54 UTC (permalink / raw)
  To: emacs-orgmode

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

Hello everyone. _o/

When I export an Org file to LaTeX and finally PDF, the code blocks and quotes often exceed the width of the page.

Is it possible to set some style of the exported blocks ? Like we can set the size for images ? I can't found it.

Thanks for your help.

----
Séb

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

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

* Re: Code blocks and quotes export style
  2022-03-13 10:54 Code blocks and quotes export style Sébastien Gendre
@ 2022-03-13 16:06 ` Kaushal Modi
  2022-03-13 18:39   ` Juan Manuel Macías
  2022-03-13 18:55 ` Barton, Mark
  1 sibling, 1 reply; 8+ messages in thread
From: Kaushal Modi @ 2022-03-13 16:06 UTC (permalink / raw)
  To: Sébastien Gendre; +Cc: emacs-org list

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

On Sun, Mar 13, 2022, 6:55 AM Sébastien Gendre <seb@k-7.ch> wrote:

> Hello everyone. _o/
>
> When I export an Org file to LaTeX and finally PDF, the code blocks and
> quotes often exceed the width of the page.
>

Hello _o/

I fixed[1] that problem by using the LaTeX minted package that allows
wrapping around the lines using its "breaklines" option.

Well, that will at least help the code blocks going out of bounds. It won't
help the quotes.

Note that I added that to my Org mode config more than 6 years back or
something. So there might be a better way to do the same but that setup
still works! :)

[1]:
https://github.com/kaushalmodi/.emacs.d/blob/c643684ad675753c69df602d7298241d05173255/setup-files/setup-org.el#L941-L972

>

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

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

* Re: Code blocks and quotes export style
@ 2022-03-13 16:22 autofrettage
  0 siblings, 0 replies; 8+ messages in thread
From: autofrettage @ 2022-03-13 16:22 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

> When I export an Org file to LaTeX and finally PDF, the code blocks and quotes often exceed the width of the page.

> Is it possible to set some style of the exported blocks ?

I wonder what the export engine can do about code which is too wide? As a programmer, I certainly wouldn't like some brainless line-breaking make a mess of my beautiful code

Most coding standards recommend lines at most 80 characters wide, or even a tad shorter, but this requires tiny letters, if generous LaTeX margins are used. ...not least with A4-paper.

Before truly smart AI shows up, the only alternative I see is writing short enough lines manually.

...but I am no expert on Org Mode.

Cheers
Rasmus


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

* Re: Code blocks and quotes export style
  2022-03-13 16:06 ` Kaushal Modi
@ 2022-03-13 18:39   ` Juan Manuel Macías
  2022-03-14 12:50     ` Max Nikulin
  0 siblings, 1 reply; 8+ messages in thread
From: Juan Manuel Macías @ 2022-03-13 18:39 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: orgmode, Sébastien Gendre

Kaushal Modi writes:

> Well, that will at least help the code blocks going out of bounds. It
> won't help the quotes. 

With the quotes going out of bounds issue it would be nice to see a
screenshot. But if a line of normal text goes outside the margin, it is
usually due to a TeX overfull hbox, perhaps because TeX hasn't been able
to hyphenate a long word correctly (also perhaps because the text is in
a language other than the main language, and that text should be encased
in the secondary language specifications).

For this type of lines outside the margin there are several LaTeX
solutions:

The quick fix is to add a discretionary hyphen (\-). For example, if the
word that goes outside the margin is "supercalifragilistic", the
discretionary can be added with an export snipett:

Supercali@@latex:\-@@fragilistic

Or even breakpoints can be indicated with the '\hyphenation' macro in the
preamble (we can add a list of words separated by commas):

#+LaTeX_Header: \hyphenation{Supercali-fragilistic}

Another solution is to disable TeX's line break algorithm at the
paragraph where the line overflows, using the slopypar environment. The
result can be ugly, with too wide separations between words.

On the other hand, loading the microtype package (in pdfTeX or LuaTeX)
usually helps a lot in the construction of the paragraphs.

And finally, if LuaTeX is used to compile, the linebreaker
(https://www.ctan.org/pkg/linebreaker) package automatically prevents
all overfull hboxes in the document.

Also note that the Org quote block supports the :environments attribute,
where we can apply environments other than 'quote', such as quotation or
those provided by the csquotes package. For example, for quotes in
another language:

#+LaTeX_Header:\usepackage[german,english]{babel}
#+LaTeX_Header:\usepackage{quoting}
#+LaTeX_Header:\usepackage[babel=true,autostyle=true,german=quotes]{csquotes}
#+LaTeX_Header:\SetBlockEnvironment{quoting}
#+ATTR_LaTeX: :environment foreigndisplayquote :options {german}
#+begin_quote
Eine Erklärung, wie sie einer Schrift in einer Vorrede nach der
Gewohnheit vorausgeschickt wird (Hegel).
#+end_quote

Best regards,

Juan Manuel 




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

* Re: Code blocks and quotes export style
  2022-03-13 10:54 Code blocks and quotes export style Sébastien Gendre
  2022-03-13 16:06 ` Kaushal Modi
@ 2022-03-13 18:55 ` Barton, Mark
  2022-03-13 21:13   ` Tim Cross
  1 sibling, 1 reply; 8+ messages in thread
From: Barton, Mark @ 2022-03-13 18:55 UTC (permalink / raw)
  To: Sébastien Gendre; +Cc: emacs-orgmode@gnu.org

I manually check the pdf to see if it fits and use a code formatter to get the line widths shorter. I use blacken for python and sqlformat for SQL within Emacs. Even then I still hit limits where I recently changed to font size to small for the code blocks.

I use minted for syntax highlighting of code blocks.
#+LaTeX_HEADER: \usepackage{minted}

I set a local variable for org using minted to change the fontsize.
# Local Variables:
# org-latex-minted-options: (("fontsize" "\\small"))
# End:

Mark

> On Mar 13, 2022, at 3:54 AM, Sébastien Gendre <seb@k-7.ch> wrote:
> 
> Hello everyone. _o/
> 
> When I export an Org file to LaTeX and finally PDF, the code blocks and quotes often exceed the width of the page.
> 
> Is it possible to set some style of the exported blocks ? Like we can set the size for images ? I can't found it.
> 
> Thanks for your help.
> Séb


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

* Re: Code blocks and quotes export style
  2022-03-13 18:55 ` Barton, Mark
@ 2022-03-13 21:13   ` Tim Cross
  0 siblings, 0 replies; 8+ messages in thread
From: Tim Cross @ 2022-03-13 21:13 UTC (permalink / raw)
  To: Barton, Mark; +Cc: emacs-orgmode@gnu.org, Sébastien Gendre


"Barton, Mark" <Mark.Barton@disney.com> writes:

> I manually check the pdf to see if it fits and use a code formatter to get the
> line widths shorter. I use blacken for python and sqlformat for SQL within
> Emacs. Even then I still hit limits where I recently changed to font size to
> small for the code blocks.
>
> I use minted for syntax highlighting of code blocks.
> #+LaTeX_HEADER: \usepackage{minted}
>
> I set a local variable for org using minted to change the fontsize.
> # Local Variables:
> # org-latex-minted-options: (("fontsize" "\\small"))
> # End:
>

That is basically what I do as well. I use minted and a smaller font for
code listings. I also ensure that when programming, I use a fill column
of 80.

In this day of large monitors, a fill column of 80 for programming
languages can often seem frustrating as it means less code in a
'screen' (window). Increasing fill column to (lets say) 100 can work
well, until it comes time to generate documentation and PDFs etc. Then I
remember why 80 is a better default!

I do use local variables more these days and will set a larger fill
column setting for code when I know I won't be needing to print it or
use it in Latex, but the default is 80 so that whenever I do org blocks,
things wrap at a width which works better for export to PDF etc.


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

* Re: Code blocks and quotes export style
  2022-03-13 18:39   ` Juan Manuel Macías
@ 2022-03-14 12:50     ` Max Nikulin
  2022-03-14 18:09       ` Juan Manuel Macías
  0 siblings, 1 reply; 8+ messages in thread
From: Max Nikulin @ 2022-03-14 12:50 UTC (permalink / raw)
  To: emacs-orgmode

On 14/03/2022 01:39, Juan Manuel Macías wrote:
> 
> Supercali@@latex:\-@@fragilistic

     Supercali\shy{}fragilistic
     Supercali\-fragilistic


should be even better since, besides LaTeX "\-", HTML exporter uses 
"&shy;" or "&#x00ad;" (I would expect more consistent behavior though.)

info "(org) Special Symbols" 
https://orgmode.org/manual/Special-Symbols.html [[info:org#Special Symbols]]



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

* Re: Code blocks and quotes export style
  2022-03-14 12:50     ` Max Nikulin
@ 2022-03-14 18:09       ` Juan Manuel Macías
  0 siblings, 0 replies; 8+ messages in thread
From: Juan Manuel Macías @ 2022-03-14 18:09 UTC (permalink / raw)
  To: Max Nikulin; +Cc: orgmode

Max Nikulin writes:

> should be even better since, besides LaTeX "\-", HTML exporter uses
> "&shy;" or "&#x00ad;" (I would expect more consistent behavior
> though.)

Hi, Maxim. You're right, I didn't remember that there is a specific
entity in Org for the discretionary hyphen. Sometimes I think too much
from the LaTeX side... :-)

Best regards,

Juan Manuel 


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

end of thread, other threads:[~2022-03-14 18:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-13 10:54 Code blocks and quotes export style Sébastien Gendre
2022-03-13 16:06 ` Kaushal Modi
2022-03-13 18:39   ` Juan Manuel Macías
2022-03-14 12:50     ` Max Nikulin
2022-03-14 18:09       ` Juan Manuel Macías
2022-03-13 18:55 ` Barton, Mark
2022-03-13 21:13   ` Tim Cross
  -- strict thread matches above, loose matches on Subject: below --
2022-03-13 16:22 autofrettage

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).