From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
Received: from mp2.migadu.com ([2001:41d0:303:e16b::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms8.migadu.com with LMTPS
	id GM1EHCrPp2VorAAAe85BDQ:P1
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Wed, 17 Jan 2024 13:59:22 +0100
Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp2.migadu.com with LMTPS
	id GM1EHCrPp2VorAAAe85BDQ
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Wed, 17 Jan 2024 13:59:22 +0100
X-Envelope-To: larch@yhetil.org
Authentication-Results: aspmx1.migadu.com;
	dkim=pass header.d=posteo.net header.s=2017 header.b=g7WImEfj;
	spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org";
	dmarc=pass (policy=none) header.from=posteo.net
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1705496362;
	h=from:from:sender:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:cc:mime-version:mime-version:
	 content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references:list-id:list-help:
	 list-unsubscribe:list-subscribe:list-post:dkim-signature;
	bh=P70/RZo/tW4CSX1WVVIOW91LeZSHGPRaG/pqdMAE2wA=;
	b=Sro6oCtLf/ieKwg5CyJGqRU0i6X3s1aI0kjyu6+qHnoolFpxFcu3zP7s8BQChn5t09m/Dc
	nENaakPWuAE8+dp8KQyDvuiMJJFEyR5DgjvbX+mepKr4EPAt+Eue+dyp8SdYw7A97tnROK
	N1pFuXbXJyDIIMVIJtL+/jCoON2ISI7ksvmplXtoZGnMM4SLa2u0PnjQhhqs07QW7VNfcS
	a+Vro1GR4i2d1faWllvfmt02rASFe70B9xD70abQxhmMiEFk+E9O+NC8q5Bjt+wcaDVCSE
	jbbNlnj782ytRNEGwLelY/VuVGD95V863D44dCqNi9sCROypheQsTTisGL1KWg==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=pass header.d=posteo.net header.s=2017 header.b=g7WImEfj;
	spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org";
	dmarc=pass (policy=none) header.from=posteo.net
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1705496362; a=rsa-sha256; cv=none;
	b=UD1UpscgBM3SIbg6NdNe0Xgplpg9rdFcOnT+iMXzoIpuRew+xseEB77svgozD8eHEEmK1N
	P/+5wOLEoy59wQeWRS6bSsh1kuO/BzQpDL4xE9P8N1u6LlJ/wDUy2bsk+3R9PsRULkBkG7
	xygWA1AGmMIPCI/PEx3GqazH1xe/Y/Gy6/gdG0k8JcokUN9CvPyDgzfIx0X8cFaWkbSWKn
	ONIDtT9Z9VEHK9T6Xk+yak4s0dgk9C9e2F2P4Tn+wM1FHRN+XL0e2G5LSSSHcnt9u+Qtg3
	mwYfwkGo+OepOPqn4f4pyMp/ZvrEsuUQwRxXABrljzh0GzpuoTwwhjZH+SfPJg==
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by aspmx1.migadu.com (Postfix) with ESMTPS id 46D9765C1A
	for <larch@yhetil.org>; Wed, 17 Jan 2024 13:59:22 +0100 (CET)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-orgmode-bounces@gnu.org>)
	id 1rQ5UI-0001iG-KN; Wed, 17 Jan 2024 07:57:46 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@posteo.net>)
 id 1rQ5UG-0001i3-T2
 for emacs-orgmode@gnu.org; Wed, 17 Jan 2024 07:57:44 -0500
Received: from mout02.posteo.de ([185.67.36.66])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@posteo.net>)
 id 1rQ5UC-000579-Ql
 for emacs-orgmode@gnu.org; Wed, 17 Jan 2024 07:57:43 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id B7AAF240103
 for <emacs-orgmode@gnu.org>; Wed, 17 Jan 2024 13:57:37 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1705496257; bh=P70/RZo/tW4CSX1WVVIOW91LeZSHGPRaG/pqdMAE2wA=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type:
 Content-Transfer-Encoding:From;
 b=g7WImEfjPHD58uXxMJd0t3EvRvYB0w9q4/UD+FVh2c1ZOTlWRunZGocpp5/u5GNnm
 W5iKzb0grJ2WdpaccbbEP27EX9iYnulPyM+82F2TdX9BgYCBLsRDo/Q+Ha1QHlSCUe
 rq3kVw3flfB1FOVt9ve8qqUKUZb3K5SGzu/LTvHxobTZ8pZFeIYocE1UtgCMbsz3hH
 DKcHmsobKig/+khWXDwXQOTGsPTeoqV5HMnh01vD71HluvFG+9736CDzszcXwg8zwN
 gqkOYHClO/h5L8Kp0ZqpNsUSC2Ew0HdUaW9J+OFV7zxewPUtDi+igxyo4TnQnfccZd
 CQnwQc64srunQ==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TFQrw5Pcmz9rxB;
 Wed, 17 Jan 2024 13:57:36 +0100 (CET)
From: Ihor Radchenko <yantar92@posteo.net>
To: Juan Manuel =?utf-8?Q?Mac=C3=ADas?= <maciaschain@posteo.net>
Cc: orgmode <emacs-orgmode@gnu.org>, Max Nikulin <manikulin@gmail.com>
Subject: Re: [possible patch] Remove the '\\[0pt]' string from the last line
 of a verse block in LaTeX export
In-Reply-To: <87il3tax9a.fsf@posteo.net>
References: <874jfvjo2k.fsf@posteo.net> <87cyu5uv7c.fsf@localhost>
 <878r4tfccn.fsf@posteo.net> <87zfx9t7di.fsf@localhost>
 <87wmsddlw5.fsf@posteo.net> <87r0ikrt5h.fsf@localhost>
 <87o7dnefwo.fsf@posteo.net> <87cyu1l69f.fsf@localhost>
 <87il3tax9a.fsf@posteo.net>
Date: Wed, 17 Jan 2024 13:00:51 +0000
Message-ID: <8734uwjerg.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net;
 helo=mout02.posteo.de
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: emacs-orgmode@gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
X-Migadu-Flow: FLOW_IN
X-Migadu-Country: US
X-Migadu-Spam-Score: -9.89
X-Migadu-Scanner: mx13.migadu.com
X-Spam-Score: -9.89
X-Migadu-Queue-Id: 46D9765C1A
X-TUID: MVaYVIu5gEux

Juan Manuel Mac=C3=ADas <maciaschain@posteo.net> writes:

>> 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.
>
> I remember the thread where these issues were discussed and the long
> discussion where many alternatives were proposed. After all, the \\[0pt]
> solution still seems the safest to me. It seems that the problem is
> located only in the verse environment, probably due to some particular
> redefinition of the \\ macro that makes that environment.

We chose \\[0pt] simply because we did not find anything better.
In fact, Max expressed some concerns about \\[0pt] - in
https://list.orgmode.org/orgmode/tik0uf$td1$1@ciao.gmane.io/ and
https://list.orgmode.org/orgmode/tio0th$vn8$1@ciao.gmane.io/

If the idea with custom command does not have obvious downsides, it
might be a better option. In the previous thread, we only considered
redefining \\ itself - obviously a non-starter for environments that
re-define \\ by their own, like here.

> In any case, square brackets are a problematic character in LaTeX
> (think, e.g., of some environment that takes an optional argument). I
> think pandoc chooses to always export them as {[}{]}:
>
> #+begin_src sh :results latex
> str=3D"[hello world] [foo] [bar]"
> pandoc -f org -t latex <<< $str
> #+end_src
>
> #+RESULTS:
> #+begin_export latex
> {[}hello world{]} {[}foo{]} {[}bar{]}
> #+end_export
>
> We could do the same, but I'm afraid it's too late if
> org-latex-line-break-safe already exists... I don't remember if
> something similar was proposed in that discussion, and it was rejected
> for some reason.

It is not too late.

AFAIR, we just decided not to dig deeper about pandoc's approach.

As for {[}{]}, it is a bit difficult to implement. Especially when we
also consider user filters and derived backends. If we have several
transcoders of consequent elements, there is always a risk that even
when a given filter/transcoder is generating a valid LaTeX code,
concatenating them may still cause issues like we have with \\.

I am wondering if there are other examples of commands with optional
arguments that may cause a similar problem with

\command
[unrelated text]

If there are, we may actually want to consider pandoc's approach
seriously.

>> We may as well strip the trailing \\[0pt] there.
>
> I think it would be best to remove the last \\[0pt] in the verse block.
> I can prepare a patch, but I'm afraid that org-latex-verse-block is
> becoming an homage to replace-regexp-in-string...

Not a big deal. Or, if you want, you can make changes via temporary
buffer; if that is cleaner.

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