Comments (20)
nice example of the issue. The reason for the extra t
is fairly clear (but also shows that there is a need to do something about it). What happens is that that the code does a simple test (assuming that the option argument is a single char), namely \if #1t\vtop \else \if #1b \vbox \else \vcenter \fi
.
so if you have a single char inside the optional argument it will not be matched, so you get \vcenter
but with \mathbf{k}
as #1
ends up being true as that gets expanded (followed by a t
so the t
prints. It could get worse :-)
So yes we need to address this but not in a rush during this week, that is too dangerous.
from latex2e.
from latex2e.
Thanks for the reply.
I would certainly prefer the new macro, but the altering of existing documents is also a big issue. So maybe it is possible to change in a way that retains current behavior, but displays a warning if [
does not immediately follow.
And, if that would take too much work (I have no idea about its difficulty), displaying a warning when the received argument is not among t, c, & b will also help unexperienced users like me a lot. Practically this will cover most cases as well, only leaving out the unlucky ones whose formula start with [t]
or so.
from latex2e.
(might be off topic)
A pair of package options named allowspaces
and disallowspaces
(default), provided by package mathtools
, does the job @davidcarlisle suggests. Maybe it can be used as a workaround.
from latex2e.
@muzimuzhi yes thanks, more generally there are some vague plans to merge parts or all of mathtools in to amsmath perhaps, one day. certainly the parts of mathtools that are "fixes" to amsmath rather than clearly extensions.
from latex2e.
from latex2e.
Something like this, perhaps (@FrankMittelbach )?
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\def\ams@t{t}\def\ams@b{b}\def\ams@c{c}
\renewcommand{\start@aligned}[2]{%
\RIfM@\else
\nonmatherr@{\begin{\@currenvir}}%
\fi
\savecolumn@ % Assumption: called inside a group
\alignedspace@left
\def\ams@tmp{#1}%
\let\ams@tmpb\@empty
\ifx\ams@tmp\ams@t\vtop\else
\ifx\ams@tmp\ams@b\vbox\else
\ifx\ams@tmp\ams@c\else
\def\ams@tmpb{[#1]}%
\fi
\vcenter
\fi\fi
\bgroup
\maxfields@#2\relax
\ifnum\maxfields@>\m@ne
\multiply\maxfields@\tw@
\let\math@cr@@@\math@cr@@@alignedat
\alignsep@\z@skip
\else
\let\math@cr@@@\math@cr@@@aligned
\alignsep@\minalignsep
\fi
\Let@ \chardef\dspbrk@context\@ne
\default@tag
\spread@equation % no-op if already called
\global\column@\z@
\ialign\bgroup
&\column@plus
\hfil
\strut@
$\m@th\displaystyle{##}$%
\tabskip\z@skip
&\column@plus
$\m@th\displaystyle{{}##}$%
\hfil
\tabskip\alignsep@
\crcr
\ams@tmpb
}
\makeatother
\begin{document}
\begin{equation}
1=\begin{aligned}
[p, q] = 1 - 1 = 0 \\
[q, p] = 1 - 1 = 0
\end{aligned}
\end{equation}
\begin{equation}
2=\begin{aligned}[t]
[p, q] = 1 - 1 = 0 \\
[q, p] = 1 - 1 = 0
\end{aligned}
\end{equation}
\begin{equation}
3=\begin{aligned}[b]
[p, q] = 1 - 1 = 0 \\
[q, p] = 1 - 1 = 0
\end{aligned}
\end{equation}
\begin{equation}
4=\begin{aligned}[c]
[p, q] = 1 - 1 = 0 \\
[q, p] = 1 - 1 = 0
\end{aligned}
\end{equation}
\end{document}
from latex2e.
from latex2e.
from latex2e.
note the version in the comment above treats []
as not an option so would typeset []
it may be better to treat it as a valid option, acting like [c]
as many editors seem to generate empty options (not necessarily for aligned, but in general) you often see \begin{table}[]
for example.
from latex2e.
Just a note on the use of: \ams@tmpb
At first I thought it looked very unsafe.
But on retreading (oops!) the code I now
see that it is βveryβ local!
Extra precaution (since the
escape of such temporary defs
is a common cause of bugs)
would be to make it empty again
after using it.
from latex2e.
I can see how empty optional May well happen due to smart editors not being clever enough to know that if a use does not actively edit the template then it should remove the delimiters.
So probably a good idea to interpret empty as c.
But this raises the question of what to do for all other empty optionals?? In all of latex.
from latex2e.
@davidcarlisle yes that is more or less what I was thinking of: doing something less surprising when the optional argument doesn't fit the spec. and yes, I think accepting an empty default in this case is probably a sensible idea too.
from latex2e.
@car222222 I may be mistakenbut most if not all of LaTeX actually already supports the use of "empty" meaning the default action whenever the optional value is a of a defined set, e.g. \begin[]{tabular}
= \begin[c]{tabular}
and the like. Probably needs some verification of that claim but I think it is largely true in core (there aren't that many)
from latex2e.
from latex2e.
from latex2e.
yes I had wondered about using edef but didn't dare. I suppose f expansion would be safer, either way I think there are too many issues (including coordination with mathtools) so I don't plan changing this this week so will miss the texlive 2018 initial release.
from latex2e.
sounds like a sensible plan. This isn't urgent
from latex2e.
Hi everyone, I also found the problem and the working example might provide some evidence. In a particular case a mysterious "t" will appear:
Minimal Working Example:
`
\RequirePackage{latexbug} % <--should be always the first line (see CONTRIBUTING)!
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\author{}
\title{}
\maketitle
\begin{equation}
[\mathbf{K}]=1
\end{equation}
\begin{equation}
\begin{aligned}
[\mathbf{K}]=1
\end{aligned}
\end{equation}
\end{document}
`
Interestingly, the second equation produces "\mathbf{K}t=1" with a redundant "t". If the first equation is absent, or "\mathbf" is not specified in either equation, the second one will produce "=1" as is already pointed.
from latex2e.
really think we should make at least sure that only c/b/t are accepted as optional argument the fact that the optional arg can start on a new line is something we can't rally change in core amsmath because it is too long ot there but dropping a bracket group is clearly an unintended bug and so is the fact that [aa]
will be interpreted as top and the group dropped.
from latex2e.
Related Issues (20)
- Conditional statements syntax HOT 5
- `\dots` not working correctly with `\cong` HOT 4
- minor doc tweaks to ltfilehook HOT 2
- source2e documentation footers/ \ProvidesFile of base .dtx HOT 3
- Possible source2e improvements HOT 3
- Automatically adjust horizontal boxes in table of contents HOT 4
- Image upscaled for no apparent reason HOT 7
- Avoid option conflicts between classs and packages HOT 4
- Test more packages before publishing a new release HOT 14
- Reformatting examples in clsguide.tex HOT 5
- fpeval expands past its argument HOT 2
- New command: \__kernel_set_arg_to_keyvalue:Nnn HOT 4
- amsmath: `{align}` inherits line-depth of above `{gather}`, results in incorrect vertical placement tags HOT 3
- `\disable@package@load` ready to be used by third-party classes? HOT 1
- \if@reversemargin wrongly documented in source code HOT 1
- expansion of key-value package options differ on the first and second call HOT 2
- \IfInstanceExistTF unavailable in 2024-06-01 pre-release 1 HOT 9
- Adding a .dir-locals.el to the project root directory HOT 5
- \afterpage from afterpage package broken with recent distribution HOT 3
- Changes in horizontal spacing in some equations HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from latex2e.