emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to preserve indentation of title inside a latex src block when exporting to LaTeX?
@ 2023-08-15 10:35 Edgar Lux
  2023-08-15 10:53 ` Edgar Lux
  2023-08-16 10:05 ` Ihor Radchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Edgar Lux @ 2023-08-15 10:35 UTC (permalink / raw)
  To: Emacs Orgmode

Hello. How to preserve indentation of title inside a latex src block when exporting to LaTeX?

For (annoying) reasons, I need a frontmatter block which is able to indent its contents. I am almost there, but the title line is not. I can edit this manually after export, but I would like to know if there is a way to do this... wait... there are filters. Is a filter the only solution? Thanks. 

#+options: toc:nil title:nil timestamp:nil

#+begin_src emacs-lisp
  (org-babel-do-load-languages 
     'org-babel-load-languages 
     '( (latex       . t) ))
#+end_src

#+begin_frontmatter
  #+begin_src latex -i :exports results :eval yes :results replace
  \title{Determine in-situ matrix properties}
  \nothing{a}
  #+end_src
#+end_frontmatter

#+caption: Notice that title is not indented, but nothing is.
#+results:
: \begin{frontmatter}
: \title{Determine in-situ matrix properties}
:  \nothing{a}
: \end{frontmatter}

#+begin_src emacs-lisp
  (concat (emacs-version) "\n" (org-version))
#+end_src

#+RESULTS:
: GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.36, cairo version 1.17.6)
:  of 2023-01-03
: 9.5.5

-- 
Sent with https://mailfence.com  
Secure and private email


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

* Re: How to preserve indentation of title inside a latex src block when exporting to LaTeX?
  2023-08-15 10:35 How to preserve indentation of title inside a latex src block when exporting to LaTeX? Edgar Lux
@ 2023-08-15 10:53 ` Edgar Lux
  2023-08-16 10:05 ` Ihor Radchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Edgar Lux @ 2023-08-15 10:53 UTC (permalink / raw)
  To: Emacs Orgmode

This didn't work (I tried)

  ;; Indent title ----
  (defun my-latex-filter-indent-title (text backend info)
    "Ensure \"\\title\" is indented in LaTeX export."
    (when (org-export-derived-backend-p backend 'latex)
      (replace-regexp-in-string
       ;; (rx (group (and (syntax escape) "title")))
       ;; (rx (and "  " (backref 1))) text)))
       "title"
       "  title" text)))

  (make-local-variable 'org-export-filter-plain-text-functions)
  (add-to-list 'org-export-filter-plain-text-functions
               'my-latex-filter-indent-title)
  ;; ---- indent title ends


On Aug 15, 2023 at 12:35 PM, Edgar Lux <edgarlux@mailfence.com> wrote:Hello. How to preserve indentation of title inside a latex src block when
exporting to LaTeX?

For (annoying) reasons, I need a frontmatter block which is able to indent its
contents. I am almost there, but the title line is not. I can edit this
manually after export, but I would like to know if there is a way to do this...
wait... there are filters. Is a filter the only solution? Thanks. 

#+options: toc:nil title:nil timestamp:nil

#+begin_src emacs-lisp
  (org-babel-do-load-languages 
     'org-babel-load-languages 
     '( (latex       . t) ))
#+end_src

#+begin_frontmatter
  #+begin_src latex -i :exports results :eval yes :results replace
  \title{Determine in-situ matrix properties}
  \nothing{a}
  #+end_src
#+end_frontmatter

#+caption: Notice that title is not indented, but nothing is.
#+results:
: \begin{frontmatter}
: \title{Determine in-situ matrix properties}
:  \nothing{a}
: \end{frontmatter}

#+begin_src emacs-lisp
  (concat (emacs-version) "\n" (org-version))
#+end_src

#+RESULTS:
: GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.36, cairo
version 1.17.6)
:  of 2023-01-03
: 9.5.5

-- 
Sent with https://mailfence.com  
Secure and private email

-- 
Sent with https://mailfence.com  
Secure and private email


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

* Re: How to preserve indentation of title inside a latex src block when exporting to LaTeX?
  2023-08-15 10:35 How to preserve indentation of title inside a latex src block when exporting to LaTeX? Edgar Lux
  2023-08-15 10:53 ` Edgar Lux
@ 2023-08-16 10:05 ` Ihor Radchenko
       [not found]   ` <1821743348.485583.1692187548513@fidget.co-bxl>
  1 sibling, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2023-08-16 10:05 UTC (permalink / raw)
  To: Edgar Lux; +Cc: Emacs Orgmode

Edgar Lux <edgarlux@mailfence.com> writes:

> Hello. How to preserve indentation of title inside a latex src block when exporting to LaTeX?
>
> For (annoying) reasons, I need a frontmatter block which is able to indent its contents. I am almost there, but the title line is not. I can edit this manually after export, but I would like to know if there is a way to do this... wait... there are filters. Is a filter the only solution? Thanks. 
>
> #+begin_frontmatter
>   #+begin_src latex -i :exports results :eval yes :results replace
>   \title{Determine in-situ matrix properties}
>   \nothing{a}
>   #+end_src
> #+end_frontmatter

I think that you may post-process the result (see :post header arg), adding indentation.

-i only affects the code block itself, not its results.

And may you please elaborate why you need to preserve indentation? We
generally assume that common indentation is not significant.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* Re: How to preserve indentation of title inside a latex src block when exporting to LaTeX?
       [not found]   ` <1821743348.485583.1692187548513@fidget.co-bxl>
@ 2023-08-16 12:14     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2023-08-16 12:14 UTC (permalink / raw)
  To: Edgar Lux; +Cc: emacs-orgmode

Edgar Lux <edgarlux@mailfence.com> writes:

>> And may you please elaborate why you need to preserve indentation? We
>> generally assume that common indentation is not significant.
>
> Collaborating with people who don't use Org, but only LaTeX, and possibly use software which reformats the spacing automatically. Then, this spacing becomes annoying from the perspective of version control systems on both ends. Free world issues, I guess (at least it's not some proprietary format).

You might also do the equivalent reformatting using Auctex after export.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

end of thread, other threads:[~2023-08-16 12:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-15 10:35 How to preserve indentation of title inside a latex src block when exporting to LaTeX? Edgar Lux
2023-08-15 10:53 ` Edgar Lux
2023-08-16 10:05 ` Ihor Radchenko
     [not found]   ` <1821743348.485583.1692187548513@fidget.co-bxl>
2023-08-16 12:14     ` Ihor Radchenko

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