2

I want to put text on the header of my document (I'm using fancyhdr), but if the text surpass certain length it overlaps with other elements. For example, if I want to put "A very long text to fit in the header", then the desired output will be "A very long text...". Of course this output depends on a given length.

In this question there is a method to obtain the length of given text. But I cannot figure out how to display just a few words of the text.

Sorry if I don't have a MWE, but I don't know how to start. I've tried \clip the text using TikZbut it cuts words, something like: "A very lon..."

Thanks in advance

Luis Turcio
  • 2,757

1 Answers1

3

There is a rather old package called truncate, so one can use

\truncate{122pt}{This text has been~truncated}

and the text will be truncated before 122pt, between words and never at a ~.

See the truncate package manual for more options

daleif
  • 54,450