LaTeX: Finding width of a given text and adding a horizontal space of that width

StackOverflow https://stackoverflow.com/questions/4124395

  •  29-09-2019
  •  | 
  •  

문제

I would like to add a white space of exactly the width of a given text. I could use \hspace{}, but then I need the width that given piece of text is going to use in my LaTeX document.

Another idea is to create an invisible box containing the text. Like \mbox{text}, but invisible. As I am pretty sure that I cannot just tell LaTeX not to print that particular box, I am sure that there is another solution.

Any ideas?

도움이 되었습니까?

해결책

You’re searching for \hphantom which creates a horizontal phantom box:

\par Here is some text
\par \hphantom{Here is some} more text.

Will result in something like this:

Here is some text
             more text
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top