GeneralHow to write \phantom text backwards?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
bbasic
Posts: 7
Joined: Tue Jul 08, 2008 4:21 pm

How to write \phantom text backwards?

Post by bbasic »

I would like command similar to \phantom, but which moves not forward, but backward. See the following example:

$k+1,k+2,k+3,\dots,\overline{2k,\phantom{1}}\hspace{-2.8mm}\underbrace{1,2,3,\dots,k,}2k+1$

I would like to do this in a more elegant way than to use \hspace with negative value.

Of course, any other solutions which show how to combine \overline and \underbrace are welcomed, but I would also like to know whether there is "backwards phantom" for other purposes.

Thank you in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to write \phantom text backwards?

Post by localghost »

There is a command \negthinspace (short form \!) which could be used here.

Code: Select all

$k+1,k+2,k+3,\dots,\overline{2k,\phantom{1}}\!\!\!\!\underbrace{1,2,3,\dots,k,}2k+1$
In this case the second part is placed more precisely. I don't know any other predefined negative space. But you can define your own ones.


Best regards
Thorsten¹
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to write \phantom text backwards?

Post by gmedina »

Just a comment: 2 \negthinspace =(aprox.) 1 \negthickspace:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$k+1,k+2,k+3,\dots,\overline{2k,\phantom{1}}\hspace{-2.8mm}\underbrace{1,2,3,\dots,k,}2k+1$

$k+1,k+2,k+3,\dots,\overline{2k,\phantom{1}}\!\!\!\!\underbrace{1,2,3,\dots,k,}2k+1$

$k+1,k+2,k+3,\dots,\overline{2k,\phantom{1}}\negthickspace\negthickspace\underbrace{1,2,3,\dots,k},2k+1$

\end{document}
Supplement:
as far as I know there are these commands for negative space:
\negthinspace (short version \!) = 3mu
\negmedspace = 4mu plus 2mu minus 4mu
\negthickspace = 5mu plus 5 mu
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

How to write \phantom text backwards?

Post by Juanjo »

Here it is an alternative that doesn't use negative space:

Code: Select all

$k+1,k+2,k+3,\dots,\makebox[0pt][l]{$\overline{\phantom{2k,1}}$}2k,\underbrace{1,2,3,\dots,k,}2k+1$
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
bbasic
Posts: 7
Joined: Tue Jul 08, 2008 4:21 pm

Re: How to write \phantom text backwards?

Post by bbasic »

Seems that there is no way to do what I described. Thank you all anyway, especially Juanjo, whose solution is very nice and I believe that it can be adapted for most of the similar problems.
Post Reply