4

Is there are right aligned text block in Org-mode, like #+begin_center #+end_center? I haven't been able to find any reference in the official docs. on the other hand, this page uses a construct #+begin_right #+end_right but this doesn't work for me in LaTeX and odt export (see my MWE below and its LaTeX export). Is this type of alignment supported in Org-mode? If it is, how can I set it? If not, would it be a large issue to implement this type of text alignment and exporters?

I'm using Org-mode version 9.1.2 with Emacs 25.3.1.

My MWE is:

#+TITLE: Test

* Heading 1

#+begin_right
This text is right-aligned.
#+end_right

My LaTeX export is (I've trimmed unnecessary packages and meta-data from the export):

% Created 2017-10-11 Wed 11:24
% Intended LaTeX compiler: pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\title{Test}

\begin{document}

\maketitle
\tableofcontents

\section{Heading 1}
\label{sec:orgd88bdfd}

\begin{right}
This text is right-aligned.
\end{right}
\end{document}

Edit(): As Simon Fromme suggested in the comments below, I've added my MWE and the output.

  • I can't replicate the issue. #+begin_right #+end_right works for me with Emacs 25.2.1 and Org-mode 8.2.10 for both HTML and Latex export. Can you provide a minimal example of org-mode Markup and generated HTML/Latex? – Simon Fromme Oct 10 '17 at 23:30
  • Dear @SimonFromme, I've added the MWE as you've suggested. Unfortunately, my LaTeX won't compile as environment {right} is not defined. I know how to setup this environment but I'm curious if this kind of alignment is officially supported in Org-mode. – Budo Zindovic Oct 11 '17 at 9:34
  • See my answer. There is no such thing as "official support" for this kind of construct. – Simon Fromme Oct 12 '17 at 2:26
  • It seems that my question was a but vague. I've edited the question a bit and I hope it is a bit clearer. – Budo Zindovic Oct 12 '17 at 7:32
3

Having an org-mode file with a block of the form

#+begin_FOObarBUZZ
some Text
#+end_FOObarBUZZ

the Latex exporter seems to wrap anything within the block in a new environment named as the lower case version of FOObarBUZZ like:

\begin{foobarbuzz}
some Text
\end{foobarbuzz} 

the HTML exporter behaves similarly and wraps the block within a div like:

<div class="foobarbuzz">
<p>
some Text
</p>
</div>

Nothing smart going on here!

Since center happens to be a pre-defined environment in Latex and the CSS class center is also part of the default CSS for HTML export in org-mode, it naturally works for both Latex and HTML export.

There is no pre-defined right environment in Latex, yet there is a CSS class right defined in the default CSS for HTML export, so that #+BEGIN_RIGHT works only in the latter case given the default org-mode configuration.

Having this said, you could define a new Latex environment right that does the alignment and reference this in your org-mode file as described here.

  • Dear @SimonFromme, thank you for the answer. I apologize as my question is a bit vague. This was my temporary solution as well but it is LaTeX specific. I was searching for something that will work for a few exporters I use (namely odt, latex and html), similar to the #+begin_center #+end_center block. – Budo Zindovic Oct 12 '17 at 7:24
  • There is no built-in way to do this as the exporters don't treat the string after #+BEGIN_ in any special way. You can say that center (HTML, Latex) and right (HTML) only happen to work by chance without further definitions of environments/classes. – Simon Fromme Oct 12 '17 at 7:35
  • Dear @SimonFromme, thank you for the input and your comment wraps it up. I'll mark your answer as accepted. – Budo Zindovic Oct 12 '17 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.