all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: "Juan Manuel Macías" <maciaschain@posteo.net>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: [possible patch] Remove the '\\[0pt]' string from the last line of a verse block in LaTeX export
Date: Tue, 16 Jan 2024 14:09:16 +0000	[thread overview]
Message-ID: <87cyu1l69f.fsf@localhost> (raw)
In-Reply-To: <87o7dnefwo.fsf@posteo.net>

Juan Manuel Macías <maciaschain@posteo.net> writes:

>>> If I'm not mistaken, in TeX '\\' can only be used in horizontal mode:
>>> that is, within a paragraph. At the end of an environment like verse
>>> (\end{verse}) you are forced to enter vertical mode, and a new paragraph
>>> starts.
>>
>> Is it true for any environment? Or just some?
>
> In principle, nothing prevents one from defining an environment for use
> in horizontal mode (within the paragraph). E.g.:
> ...
> But the usual thing is that the beginning/end of an environment changes to
> vertical mode, with \par or something more elaborate.

This is annoying.
ox-latex has some transcoders that unconditionally add \\ at the
end: clocks and planning lines. If they happen to be at the end of an
environment, it can be problematic.

> hmm... I don't know if this should be considered a bug. We may think
> that \\[0pt] should never do anything, but we must keep in mind that the
> end of the verse environment is the end of a paragraph, and it changes
> to vertical mode. And the end of a paragraph is an illogical place to
> put that command. But it seems that it also alters things when it is at
> that point. Check out this reply from David Carlisle
> (https://tex.stackexchange.com/a/82666):

The very reason we use \\[0pt] is because it supposed to prevent
interpreting [...] at the new line/transcoded element as argument.

You demonstrated that it is yet not always safe enough.

May it be better to use something like

\newcommand\nothing{}
\newcommand{\safenewline}{\\\nothing}

And then use \safenewline instead of \\[0pt]

In my tests,

\begin{center}
\begin{tabular}{ll}
[t] & s\safenewline
[I] & A\safenewline
[m] & kg\safenewline
\end{tabular}
\end{center}

Does not suffer from misinterpreting new line as argument.

> If there are environments that redefine \\, such as verse or tabular,
> probably putting the optional argument of \\ with a value of 0pt at the
> end of verse alters the calculation of the normal space after the
> environment, making it shorter. I think that here we would not have a
> LaTeX bug, because the syntax of the verse environment itself says that
> the last line should not carry any \\ mark. 

AFAIU, \safenewline should still use re-defined version of \\ according
to the context.

> At the end of the tables I have not noticed any side effects. But in the
> export of the verse block, I would be in favor of somehow eliminating
> that last \\[0pt].

`org-latex-verse-block' already has a giant regexp replacement:

      ;; In a verse environment, add a line break to each newline
      ;; character and change each white space at beginning of a line
      ;; into a normal space, calculated with `\fontdimen2\font'.  One
      ;; or more blank lines between lines are exported as a single
      ;; blank line.  If the `:lines' attribute is used, the last
      ;; verse of each stanza ends with the string `\\!', according to
      ;; the syntax of the `verse' package. The separation between
      ;; stanzas can be controlled with the length `\stanzaskip', of
      ;; the aforementioned package.  If the `:literal' attribute is
      ;; used, all blank lines are preserved and exported as
      ;; `\vspace*{\baselineskip}', including the blank lines before
      ;; or after CONTENTS.

We may as well strip the trailing \\[0pt] there.

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


  reply	other threads:[~2024-01-16 14:07 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02 23:46 [possible patch] Remove the '\\[0pt]' string from the last line of a verse block in LaTeX export Juan Manuel Macías
2024-01-13 15:08 ` Ihor Radchenko
2024-01-13 16:05   ` Juan Manuel Macías
2024-01-13 18:28     ` Ihor Radchenko
2024-01-13 20:22       ` Juan Manuel Macías
2024-01-14 12:33         ` Ihor Radchenko
2024-01-14 21:58           ` Juan Manuel Macías
2024-01-16 14:09             ` Ihor Radchenko [this message]
2024-01-16 19:33               ` Juan Manuel Macías
2024-01-17 13:00                 ` Ihor Radchenko
2024-01-17 15:58                   ` Max Nikulin
2024-01-17 17:50                   ` Juan Manuel Macías
2024-01-18 13:05                     ` Ihor Radchenko
2024-01-19 17:28                       ` Juan Manuel Macías
2024-01-20 12:34                         ` Ihor Radchenko
2024-01-20 13:22                           ` Juan Manuel Macías
2024-01-20 13:46                             ` Ihor Radchenko
2024-01-20 15:41                               ` Juan Manuel Macías
2024-01-20 18:47                                 ` Ihor Radchenko
2024-01-20 20:27                                   ` Juan Manuel Macías
2024-01-21 13:42                                     ` Ihor Radchenko
2024-01-21 19:25                                       ` Juan Manuel Macías
2024-01-31 11:39                                       ` Ihor Radchenko
2024-01-21  6:06                                   ` Max Nikulin
2024-01-20 10:09                       ` Max Nikulin
2024-01-20 10:57                         ` Juan Manuel Macías
2024-01-20 12:41                         ` Ihor Radchenko
2024-01-21  5:56                           ` Max Nikulin
2024-01-20 10:27   ` Max Nikulin
2024-01-20 12:35     ` Ihor Radchenko
2024-01-21  5:44       ` Max Nikulin
2024-01-31 15:09         ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cyu1l69f.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=maciaschain@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.