# Horizontal spacing commands: \>, \hfill #164

Closed
opened this Issue Nov 3, 2014 · 20 comments

Projects
None yet
6 participants
Contributor

### xymostech commented Nov 3, 2014

 We have some spacing commands, but it appears we missed one. There might be more that we missed.

### Gupocca added a commit to Gupocca/KaTeX that referenced this issue Dec 18, 2014

 Added \thinspace. Resolves KaTeX#164. 
 b3f2cad 
Member

### kevinbarabash commented Jun 29, 2015

 We currently support: \!, \, \,, \;, \:, ~, \space, \enspace, \quad, \qquad, and \phantom. We're missing: \>, \thinspace, \hspace, \hfill, \kern, and \hphantom. Notes: \thinspace is an alias for \, \hphantom is not an alias for \phantom, according to TeXBook pg 178: There’s also \hphantom, which has the width of a \phantom, but its height and depth are zero.

Closed

Closed

Collaborator

### gagern commented Jul 8, 2015

 The way I see it, \kern is often followed by a dimension without braces around it. Would we want to support that as well? If so, we would have to adjust the parsing of sizes in my macros branch, at least if we actually follow some variant of that branch to implement macros.
Member

### kevinbarabash commented Jul 8, 2015

 I guess we'd have to. Should probably have a lexSize function.
Collaborator

### gagern commented Jul 8, 2015

 Nah, we shouldn't do this in the lexer, but on the token stream. That's what TeX does, as far as I understand things.
Member

### kevinbarabash commented Jul 8, 2015

 That could work to. It seems like using a regex directly on the input stream would be easier as opposed to having to concatenate tokens would be trickier. I know there's code there that does this already, but it relies on a hard stop which we wouldn't have in this situation.
Collaborator

### gagern commented Jul 8, 2015

 I think a length would be finished after its two letter unit has been parsed. But I'd have to read The TeX Book to verify this first.
Member

### kevinbarabash commented Jul 8, 2015

 I think a length would be finished after its two letter unit has been parsed. For sure, it's a little trickier than checking for a "]".
Collaborator

### gagern commented Jul 8, 2015

 True, but it has the benefit of working even if there is some macro expansion involved in the length notation.

Closed

### michaelcadilhac commented Mar 29, 2017

 Any update on that? It seems that hspace is a reasonable thing to have indeed. Cheers.
Member

### kevinbarabash commented Apr 16, 2017

 @michaelcadilhac we do have macros now, and we do support \kern now

### michaelcadilhac commented Apr 16, 2017

 @kevinbarabash certainly, hence why not hspace?
Member

### kevinbarabash commented Apr 16, 2017

 @michaelcadilhac just haven't gotten it, mainly busy with other stuff and there's a pile of almost-there PRs that I should finish first. PRs are welcome though.
Member

### edemaine commented Apr 16, 2017

 Is there a difference between \hspace and \kern, in either math or text mode? If not, I can throw together a macro-based PR. Here's a list of various horizontal spacing commands, which we should review for support.
Member

### edemaine commented Apr 16, 2017

 OK, so here's the difference: \kern supports units mu and ex only, and no plus or minus arguments, whereas \hskip/\hspace supports lots of units and plus/minus arguments. I don't see plus/minus as important in KaTeX (it's not like we have boxes whose width we can adjust), but supporting other units would be important. Incidentally, most other commands listed above work fine in KaTeX, including the very useful \quad, \qquad, and ~.
Collaborator

### gagern commented Apr 20, 2017

 plus, minus and stretchable glue might become relevant at some point if we manage to use flex boxes to model these. Should be possible, at least in theory and for some situations. Not sure how urgent this is, so I'd say we shouldn't block on support for it.

### Casyfill commented Jun 16, 2017

 oh, waiting is hard... :-)
Member

### edemaine commented Jun 17, 2017

 @Casyfill If you want \hspace to work now, try defining a macro mapping it to \kern. \kern is essentially behaving like \hspace now, and will work with units of em and ex. \kern should behave differently, and I'll work on a PR to that effect, but this is a good stopgap for now. We're also working on unit support on #732, which is still a work in progress, and has some discussion about best way to do it -- feel free to join in.

Closed

Merged

### kevinbarabash added a commit that referenced this issue Sep 2, 2017

 Add \smash, laps, spaces, and phantoms (#833) 
* Add \smash, laps, spaces, and phantoms

1. Support \smash, including the optional argument from AMS.

2. Change \llap and \rlap so that they render in text style. Repeat: This *changes* KaTeX behavior.

3. Add \mathllap and \mathrlap. These will act as they do  in mathtools and as in previous KaTeX versions of \llap and \rlap.

4. Add \mathclap and \clap.

5. Add \hphantom and \vphantom.

6. Add \thinspace, \medspace, \thickspace

7. Add \hspace.

This work will resolve issue #270 and parts of #50 and #164.

A. Perlis has written a [concise description](https://www.math.lsu.edu/~aperlis/publications/mathclap/perlis_mathclap_24Jun2003.pdf) of items 1 thru 5. Except for \smash's optional argument. It's described in the [AMS User's Guide](http://texdoc.net/texmf-dist/doc/latex/amsmath/amsldoc.pdf).

Item 6 also comes from the AMS User's Guide.

* Fix test spec

* Exploit makeVList for smash

* update smash and phantom screenshots for chrome

* Change test from \llap to \mathlap

\llap is fundamentally a text-mode function. We should not expect it to work correctly when given math-mode arguments. So test \mathllap instead.

* Correct \llap macro

A correction. The previous macro returned an error if given an argument with math-mode content, such as x^2.

The corrected macro will not return an error. It will instead return well rendered math, but letters are in \mathrm font.

* update \llap, \rlap, \clap macros to use \textrm

* update Lap screenshots
 092aa0c 
Member

### kevinbarabash commented Sep 2, 2017

 The two remaining commands are \> and \hfill.

Open

Member

### edemaine commented Nov 19, 2017

 To clarify, #833 added basic support for \hspace (everything except plus and minus). I'm also looking at supporting \hspace* (as an alias to \hspace).

Merged

Merged

Open

Member

### kevinbarabash commented Oct 25, 2018

 Closing this in favour of #990 since all horizontal spacing commands other than \hfil` et al have been implemented.