[LyX/master] Implement properly \limits and \nolimits
Enrico Forestieri
forenr at lyx.org
Wed Sep 9 13:26:50 UTC 2020
On Wed, Sep 09, 2020 at 12:01:32PM +0200, Jean-Marc Lasgouttes wrote:
> Le 09/09/2020 à 11:00, Enrico Forestieri a écrit :
> > > Do you have a concrete case in mind where deriving requirements from the
> > > contents of the macro goes wrong? Note that in this case, we could decide
> > > that the requirements given to the macro override whatever is decided from
> > > its contents.
> >
> > The point is that the macros defined in the symbols file are only used
> > for on-screen representation. Their definition will never appear in the
> > output. So, if \int is defined in the symbols file as
> >
> > \def\int{\intop\nolimits} esint|amsmath
> >
> > meaning that it requires either esint or masmath, the requirements for
> > \intop should not be taken into account because \intop will never
> > appear in the latex file.
>
> But \intop can appear in a LaTeX file, and it should work. So we have to set
> the requirements of \intop anyway.
Sure, and, indeed, when \intop appears its requirements are accounted for.
> > Here, the definition of \int is only used
> > for representing it on the screen. For example, if you define
> >
> > \def\int{\vcentcolon} esint|amsmath
> >
> > because you like to see \vcentcolon instead of \int on screen, then
> > you would get the package mathtools as a requirement. But \vcentcolon
> > does not really appear in the output and that requirement is bogus.
>
> I understand that but:
>
> 1/ we do not want to do such bogus things in symbols file, unless you
> have a better use case in mind.
That was only an example. However, the actual definition of \int is using
\intop and this was bringing in also its requirements. This was the cause
of the problem reported by Scott.
> 2/ this is why I proposed that in the case where requirements are given
> for the macro, the requirements induced by the definition are
> skipped.
This is exactly what the patch I applied is doing.
> The proposal 2/ is of course not 100% precise, since it is difficult to make
> a difference between "no requirement needed" and "no requirement given".
I don't understand. If the macro has a requirement (as far as latex is
concerned), it has to be listed and will be taken into account. If no
requirement is given, it means that pristine latex can deal with it.
> But in practice it seems easier in terms of maintenance to let LyX infer the
> requirements.
I fear there is a misunderstanding here. LyX does infer the requirements
for a user defined macro, but should not do it for the macros in the
symbols file. See the attached, where \int is redefined so that it now
requires the wasysym package.
--
Enrico
-------------- next part --------------
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 598
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\use_default_options true
\maintain_unincluded_children no
\language english
\language_package default
\inputencoding utf8
\fontencoding auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_roman_osf false
\font_sans_osf false
\font_typewriter_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
\use_dash_ligatures true
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\float_placement class
\float_alignment class
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\use_minted 0
\use_lineno 0
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle default
\tablestyle default
\tracking_changes false
\output_changes false
\change_bars false
\postpone_fragile_content true
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\docbook_table_output 0
\end_header
\begin_body
\begin_layout Standard
\begin_inset FormulaMacro
\renewcommand{\int}{\HF\mkern-24mu\intop}
\end_inset
\begin_inset Formula
\[
\int
\]
\end_inset
\end_layout
\end_body
\end_document
More information about the lyx-devel
mailing list