emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Are 'placement' and 'float' "obsolete terms" in inline images exported to LaTeX?
@ 2023-10-01 15:08 Juan Manuel Macías
  2023-10-01 18:07 ` Juan Manuel Macías
  2023-10-02 13:10 ` Ihor Radchenko
  0 siblings, 2 replies; 9+ messages in thread
From: Juan Manuel Macías @ 2023-10-01 15:08 UTC (permalink / raw)
  To: orgmode

 I don't know if this nomenclature issue that I'm going to raise is
excessively formalist, but here it goes.

Since the header arg :float now supports any string in inline images
exported to latex (that is, ':float foo' is exported as the environment
\begin{foo}…\end{foo}), the header arg :placement can be used for more
than just "placement". For example, this:

┌────
│ #+ATTR_LaTeX: :float minipage :placement {\textwidth}
│ [[file:/usr/share/texmf-dist/tex/latex/mwe/example-image-a.jpg]]
└────

produces in LaTeX this:

┌────
│ \begin{minipage}{\textwidth}
│ \centering
│ \includegraphics[width=.9\linewidth]{/usr/share/texmf-dist/tex/latex/mwe/example-image-a.jpg}
│ \end{minipage}
└────

(in this case :placement is exported as the required minipage argument,
which is its width).

An example of more "unexpected" (but very practical) uses is this one
with three subfigures and the subcaption package:

┌────
│ #+caption: Main caption
│ #+begin_figure
│ #+CAPTION: subcaption 1
│ #+ATTR_LaTeX: :float subfigure :placement {\textwidth} :center nil :width \textwidth
│ [[file:/usr/share/texmf-dist/tex/latex/mwe/example-image-a.jpg]]
│ @@latex:\vspace{2ex}@@
│ #+CAPTION: subcaption 2
│ #+ATTR_LaTeX: :float subfigure :placement {.4\textwidth} :center nil :width \textwidth
│ [[file:/usr/share/texmf-dist/tex/latex/mwe/example-image-a.jpg]]
│ @@latex:\hfill@@
│ #+CAPTION: subcaption3
│ #+ATTR_LaTeX: :float subfigure :placement {.4\textwidth} :center nil :width \textwidth
│ [[file:/usr/share/texmf-dist/tex/latex/mwe/example-image-a.jpg]]
│ #+end_figure
└────

(In all three subfigures, :placement is exported as the subfigure
environment argument, which designates the width of each subfigure).

I think this is a case where certain elements of Org have evolved
(consciously or unconsciously) ahead of the names, and these names have
become somewhat outdated. There is not only the case of :placement. Even
:float seems imprecise, since can be used to create a minipage, and the
minipage environment is not a float environment. Would it be worth
making those names obsolete (with backward compatibility, of course) and
replacing them with slightly more precise ones? I think that new names
would give the user an idea of more variety of uses, like the examples I
have put here.

Best regards,

Juan Manuel 


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

* Re: Are 'placement' and 'float' "obsolete terms" in inline images exported to LaTeX?
  2023-10-01 15:08 Are 'placement' and 'float' "obsolete terms" in inline images exported to LaTeX? Juan Manuel Macías
@ 2023-10-01 18:07 ` Juan Manuel Macías
  2023-10-02 13:10 ` Ihor Radchenko
  1 sibling, 0 replies; 9+ messages in thread
From: Juan Manuel Macías @ 2023-10-01 18:07 UTC (permalink / raw)
  To: orgmode

Juan Manuel Macías writes:

> Since the header arg :float now supports any string in inline images[...]

Sorry, I meant "the LaTeX attribute :float ..."


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

* Re: Are 'placement' and 'float' "obsolete terms" in inline images exported to LaTeX?
  2023-10-01 15:08 Are 'placement' and 'float' "obsolete terms" in inline images exported to LaTeX? Juan Manuel Macías
  2023-10-01 18:07 ` Juan Manuel Macías
@ 2023-10-02 13:10 ` Ihor Radchenko
  2023-10-02 14:55   ` Juan Manuel Macías
  1 sibling, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2023-10-02 13:10 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

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

> An example of more "unexpected" (but very practical) uses is this one
> with three subfigures and the subcaption package:
>
> ┌────
> │ #+caption: Main caption
> │ #+begin_figure
> │ #+CAPTION: subcaption 1
> │ #+ATTR_LaTeX: :float subfigure :placement {\textwidth} :center nil :width \textwidth
> │ [[file:/usr/share/texmf-dist/tex/latex/mwe/example-image-a.jpg]]
> ...
> I think this is a case where certain elements of Org have evolved
> (consciously or unconsciously) ahead of the names, and these names have
> become somewhat outdated. There is not only the case of :placement. Even
> :float seems imprecise, since can be used to create a minipage, and the
> minipage environment is not a float environment. Would it be worth
> making those names obsolete (with backward compatibility, of course) and
> replacing them with slightly more precise ones? I think that new names
> would give the user an idea of more variety of uses, like the examples I
> have put here.

I am not sure about obsolete - I see not reason to obsolete the intended
use case. Your example is rather an abuse.

What we might do it to introduce something like a new :wrap attribute:

#+attr_latex: :wrap subfigure,{\textwidht}

I think we have discussed something similar in the past, but more
generic - allow wrapping arbitrary Org elements (headings, drawers,
paragraphs, etc) on 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] 9+ messages in thread

* Re: Are 'placement' and 'float' "obsolete terms" in inline images exported to LaTeX?
  2023-10-02 13:10 ` Ihor Radchenko
@ 2023-10-02 14:55   ` Juan Manuel Macías
  2023-10-04  9:12     ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Juan Manuel Macías @ 2023-10-02 14:55 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: orgmode

Ihor Radchenko writes:

>> ┌────
>> │ #+caption: Main caption
>> │ #+begin_figure
>> │ #+CAPTION: subcaption 1
>> │ #+ATTR_LaTeX: :float subfigure :placement {\textwidth} :center nil :width \textwidth
>> │ [[file:/usr/share/texmf-dist/tex/latex/mwe/example-image-a.jpg]]
>> ...
>> I think this is a case where certain elements of Org have evolved
>> (consciously or unconsciously) ahead of the names, and these names have
>> become somewhat outdated. There is not only the case of :placement. Even
>> :float seems imprecise, since can be used to create a minipage, and the
>> minipage environment is not a float environment. Would it be worth
>> making those names obsolete (with backward compatibility, of course) and
>> replacing them with slightly more precise ones? I think that new names
>> would give the user an idea of more variety of uses, like the examples I
>> have put here.
>
> I am not sure about obsolete - I see not reason to obsolete the intended
> use case. Your example is rather an abuse.

Why abuse? First, it works like a charm. Second, if :float can support
any string as an environment name, why not minipage or subfigure? As for
:placement, the term would seem more precise to me if it were really
"placement" (as :align in tables is actually "align"), not LaTeX code
passed directly after the \begin{...}. That a user can put things like
this (I do it often, and I think I'm not the only one):

:placement [htbp]\SomeExtraLaTeXCode...

it is a consequence of the above. It is not an "orthodox" use (I mean,
it's not described in the manual), but it works without problems. Again,
I don't want to seem too picky about the names, but a user who doesn't
understand the source code might think that :placement only supports
things like [htbp]. My idea here is: instead of implementing new
features, recycle and take advantage of those that arise unexpectedly
:-). Although :placement was created thinking about putting code related
to placement figures, as it is implemented I would have called it
:latex-code or something similar.


> What we might do it to introduce something like a new :wrap attribute:
>
> #+attr_latex: :wrap subfigure,{\textwidht}

That would be nice if with a single latex_attr line you could export a
single figure environment for several images, since every subfigure
environment must be inside a figure environment. And putting a single
subfigure inside a figure environment doesn't make much sense. Other
than that, the idea of :wrap is good. I find it very useful, especially
on tables.

> I think we have discussed something similar in the past, but more
> generic - allow wrapping arbitrary Org elements (headings, drawers,
> paragraphs, etc) on export.

I remember that thread. In fact, I think I created a TODO to study that,
but due to lack of time I haven't been able to take a look at it.

-- 
Juan Manuel Macías

https://juanmanuelmacias.com

https://lunotipia.juanmanuelmacias.com

https://gnutas.juanmanuelmacias.com


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

* Re: Are 'placement' and 'float' "obsolete terms" in inline images exported to LaTeX?
  2023-10-02 14:55   ` Juan Manuel Macías
@ 2023-10-04  9:12     ` Ihor Radchenko
  2023-10-04 14:34       ` Juan Manuel Macías
  0 siblings, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2023-10-04  9:12 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

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

>> I am not sure about obsolete - I see not reason to obsolete the intended
>> use case. Your example is rather an abuse.
>
> Why abuse? First, it works like a charm. Second, if :float can support
> any string as an environment name, why not minipage or subfigure? As for
> :placement, the term would seem more precise to me if it were really
> "placement" (as :align in tables is actually "align"), not LaTeX code
> passed directly after the \begin{...}. That a user can put things like
> this (I do it often, and I think I'm not the only one):
>
> :placement [htbp]\SomeExtraLaTeXCode...
>
> it is a consequence of the above. It is not an "orthodox" use (I mean,
> it's not described in the manual), but it works without problems. Again,
> I don't want to seem too picky about the names, but a user who doesn't
> understand the source code might think that :placement only supports
> things like [htbp]. My idea here is: instead of implementing new
> features, recycle and take advantage of those that arise unexpectedly
> :-). Although :placement was created thinking about putting code related
> to placement figures, as it is implemented I would have called it
> :latex-code or something similar.

:float is only used for (1) tables; (2) src-blocks; (3) inline images
that are a sole element in their paragraph. But not for other Org syntax
elements - you cannot, for example, wrap a paragraph or heading into
custom environment with :float.

Further, we also provide :environment and :options attributes that do
the same thing, but without special treatment of standard
t/multicolumn/wrap/sideways/nil values in :float.

>> What we might do it to introduce something like a new :wrap attribute:
>>
>> #+attr_latex: :wrap subfigure,{\textwidht}

So, it might be even better idea to extend :environment/:options
attributes to more elements - their names make more sense and the values
do not have a pre-defined special meanings.

-- 
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] 9+ messages in thread

* Re: Are 'placement' and 'float' "obsolete terms" in inline images exported to LaTeX?
  2023-10-04  9:12     ` Ihor Radchenko
@ 2023-10-04 14:34       ` Juan Manuel Macías
  2023-10-06 16:29         ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Juan Manuel Macías @ 2023-10-04 14:34 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: orgmode

Ihor Radchenko writes:

> Further, we also provide :environment and :options attributes that do
> the same thing, but without special treatment of standard
> t/multicolumn/wrap/sideways/nil values in :float.

t/multicolumn/wrap/sideways/nil... and any arbitrary value (see lines 14125
and 14262 in org-manual.org).

>>> What we might do it to introduce something like a new :wrap attribute:
>>>
>>> #+attr_latex: :wrap subfigure,{\textwidht}
>
> So, it might be even better idea to extend :environment/:options
> attributes to more elements - their names make more sense and the values
> do not have a pre-defined special meanings.

Currently it is not possible in inline images (if I don't miss anything) this:

#+ATTR_LaTeX: :environment minipage :options {\textwidth}
[[file:/usr/share/texmf-dist/tex/latex/mwe/example-image-a.jpg]]

Implementing :environment/:options here would result in redundancy with:

#+ATTR_LaTeX: :float minipage :placement {\textwidth}
[[file:/usr/share/texmf-dist/tex/latex/mwe/example-image-a.jpg]]

which produces the same.

In tables there is more consistency because :float is a float
environment (table or any arbitrary value) and :environment is a table
environment (tabular or any arbitrary value). Here :placement :options
and :align act as what is expected of them:

#+ATTR_LaTeX: :environment foo :float var :placement [!h] :options [blah] :align cccc
|a|a|a|a|

===>

\begin{var}[!h]
\centering
\begin{foo}[blah]{cccc}
a & a & a & a\\[0pt]
\end{foo}
\end{var}
\end{document}

-- 
Juan Manuel Macías

https://juanmanuelmacias.com

https://lunotipia.juanmanuelmacias.com

https://gnutas.juanmanuelmacias.com



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

* Re: Are 'placement' and 'float' "obsolete terms" in inline images exported to LaTeX?
  2023-10-04 14:34       ` Juan Manuel Macías
@ 2023-10-06 16:29         ` Ihor Radchenko
  2023-10-06 18:35           ` Juan Manuel Macías
  0 siblings, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2023-10-06 16:29 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

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

> Ihor Radchenko writes:
>
>> Further, we also provide :environment and :options attributes that do
>> the same thing, but without special treatment of standard
>> t/multicolumn/wrap/sideways/nil values in :float.
>
> t/multicolumn/wrap/sideways/nil... and any arbitrary value (see lines 14125
> and 14262 in org-manual.org).

My point is that actual "t", "multicolumn", "wrap", "sideways", and
"nil" LaTeX environments are not allowed.

>> So, it might be even better idea to extend :environment/:options
>> attributes to more elements - their names make more sense and the values
>> do not have a pre-defined special meanings.
>
> Currently it is not possible in inline images (if I don't miss anything) this:
>
> #+ATTR_LaTeX: :environment minipage :options {\textwidth}
> [[file:/usr/share/texmf-dist/tex/latex/mwe/example-image-a.jpg]]

Sure. But we might as well implement :environment support in addition to :float.

> Implementing :environment/:options here would result in redundancy with:
>
> #+ATTR_LaTeX: :float minipage :placement {\textwidth}
> [[file:/usr/share/texmf-dist/tex/latex/mwe/example-image-a.jpg]]
>
> which produces the same.

Sure. But didn't you motivate the change with the confusing _name_
:float? IMHO, :environment is more clear.

> In tables there is more consistency because :float is a float
> environment (table or any arbitrary value) and :environment is a table
> environment (tabular or any arbitrary value). Here :placement :options
> and :align act as what is expected of them:
>
> #+ATTR_LaTeX: :environment foo :float var :placement [!h] :options [blah] :align cccc
> |a|a|a|a|
>
> ===>
>
> \begin{var}[!h]
> \centering
> \begin{foo}[blah]{cccc}
> a & a & a & a\\[0pt]
> \end{foo}
> \end{var}
> \end{document}

This is not documented and is possibly a bug.

-- 
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] 9+ messages in thread

* Re: Are 'placement' and 'float' "obsolete terms" in inline images exported to LaTeX?
  2023-10-06 16:29         ` Ihor Radchenko
@ 2023-10-06 18:35           ` Juan Manuel Macías
  2023-10-06 19:49             ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Juan Manuel Macías @ 2023-10-06 18:35 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: orgmode

Ihor Radchenko writes:

>> In tables there is more consistency because :float is a float
>> environment (table or any arbitrary value) and :environment is a table
>> environment (tabular or any arbitrary value). Here :placement :options
>> and :align act as what is expected of them:
>>
>> #+ATTR_LaTeX: :environment foo :float var :placement [!h] :options [blah] :align cccc
>> |a|a|a|a|
>>
>> ===>
>>
>> \begin{var}[!h]
>> \centering
>> \begin{foo}[blah]{cccc}
>> a & a & a & a\\[0pt]
>> \end{foo}
>> \end{var}
>> \end{document}
>
> This is not documented and is possibly a bug.

I would say that it is the expected behavior: :float is for a float
environment and :environment is for the environment that builds the
table (by default tabular). According to the manual:

#+begin_quote
The table environments by default are not floats in LaTeX.  To make
them floating objects use =:float= with one of the following
options: =t= (for a default =table= environment), =sideways= (for a
=sidewaystable= environment), =multicolumn= [...] and
=nil=.  In addition to these three values, =:float= can pass through
any arbitrary value, for example a user-defined float type with the
=float= LaTeX package
#+end_quote

and (for :environment):

#+begin_quote
Set the default LaTeX table environment for the LaTeX export
backend to use when exporting Org tables.  Common LaTeX table
environments are provided by these packages: tabularx, longtable,
array, tabu, and bmatrix.  For packages, such as tabularx and tabu,
or any newer replacements
#+end_quote

The difference is that with images, except in cases of somewhat more
complex constructions where there are subfigures, there is only one
environment, "figure" by default or any other arbitrary one. There was a
commit a while ago, I don't remember when, that allowed :float to
support any arbitrary string as the float environment name, in images
and tables. In images ':float t' is figure (by default) and in tables it
is table (also by default).

Update: ah, I already have the commit located, because I also remember
that I myself sent a patch to update the documentation and correct a
regression that that commit introduced (:float t produced an environment
"t" (\begin{t}...\end{t}):

https://list.orgmode.org/878ruhrvfq.fsf@posteo.net/


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

* Re: Are 'placement' and 'float' "obsolete terms" in inline images exported to LaTeX?
  2023-10-06 18:35           ` Juan Manuel Macías
@ 2023-10-06 19:49             ` Ihor Radchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Ihor Radchenko @ 2023-10-06 19:49 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

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

> Ihor Radchenko writes:
>
>>> In tables there is more consistency because :float is a float
>>> environment (table or any arbitrary value) and :environment is a table
>>> environment (tabular or any arbitrary value). Here :placement :options
>>> and :align act as what is expected of them:
>>>
>>> #+ATTR_LaTeX: :environment foo :float var :placement [!h] :options [blah] :align cccc
>>> |a|a|a|a|
>> ...
>> This is not documented and is possibly a bug.
>
> I would say that it is the expected behavior: :float is for a float
> environment and :environment is for the environment that builds the
> table (by default tabular). According to the manual:

Oops. You are indeed right. I missed that both :float and :environment
are documented for tables.

> The difference is that with images, except in cases of somewhat more
> complex constructions where there are subfigures, there is only one
> environment, "figure" by default or any other arbitrary one. There was a
> commit a while ago, I don't remember when, that allowed :float to
> support any arbitrary string as the float environment name, in images
> and tables. In images ':float t' is figure (by default) and in tables it
> is table (also by default).

So, the difference between :environment and :float is that :float also
encapsulates \caption in addition to the actual environment (like
tabularx or includegraphics) used for transcoded exported element.

I can see how :float+:placement can be imprecise and that the existing
:environment indeed serves a different purpose. (It might be worth
clarifying this distinction in the manual - it seems arbitrary from the
first glance).

But what would be the better name then?

-- 
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] 9+ messages in thread

end of thread, other threads:[~2023-10-06 19:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-01 15:08 Are 'placement' and 'float' "obsolete terms" in inline images exported to LaTeX? Juan Manuel Macías
2023-10-01 18:07 ` Juan Manuel Macías
2023-10-02 13:10 ` Ihor Radchenko
2023-10-02 14:55   ` Juan Manuel Macías
2023-10-04  9:12     ` Ihor Radchenko
2023-10-04 14:34       ` Juan Manuel Macías
2023-10-06 16:29         ` Ihor Radchenko
2023-10-06 18:35           ` Juan Manuel Macías
2023-10-06 19:49             ` 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).