I'm beginning to write my personal *.sty file and I would like it to be able to automatically wrap the document title in case it's too long (I'm not sure whether "wrap" is the correct term: I mean to automatically display it on more than one line if need be).

My *.sty file looks like this (I'm not a TeX\LaTeX expert, so it's based on another *.sty file with some slight modifications):


% Some code
\newcommand{\@titolo}{Senza Titolo}
% Some code

    \halign{\hbox to\textwidth{\strut\hfil##\hfil}\cr

% Some code

So, the question is: is there a way to automatically display the title on more than one line? I've tried by inserting \@titolo inside a \minipage but wasn't able to succeed. Any kind of help or hint is appreciated.

  • 2
    Welcome, \bf is obsolete for more than twenty years. Redefining \\ doesn't seem like a good idea either. LARGE is not an environment. hboxes cannot be broken in differente lines. Personally, i would not base my package on that package you are using.
    – Johannes_B
    Sep 10, 2016 at 8:20
  • How to customize my titlepage?
    – Johannes_B
    Sep 10, 2016 at 8:20
  • 2
    where did the code you start from come from? \vfil does nothing in that position, \bf shouldn't be used in latex (it's not defined by default) and using a primitive \halign rather than a latex construct such as tabular will have weird side effects. The title would wrap automatically if you did not put it in the halign. Sep 10, 2016 at 8:20
  • @DavidCarlisle, I've rewritten the code using a tabular environment and it worked out just fine. The code dated back to 2006, but I didn't expect it to be obsolete, thanks for letting me know. @Johannes_B, I'll definetly take a look at that link in the future.
    – DavideM
    Sep 10, 2016 at 14:19

1 Answer 1


Seems silly to answer to my own question, but as a reference I'll write a working solution that I was able to write thanks to the help received through the comments and some research on LaTeX book by wikibooks.org. I simply substituted the {\vfil ...} part with a \tabular environment:


The title (\@titolo) wraps just fine and it is bold.

  • Please have a look at en.wikibooks.org/wiki/LaTeX/…. There is absolutely no need to use a tabular environment with a parbox inside. All this gets you is a warning if you are in the wrong place.
    – Johannes_B
    Sep 10, 2016 at 20:32
  • That gives me the possibility of choosing the width of the title, doesn't it?
    – DavideM
    Sep 11, 2016 at 8:26
  • Yes, it does. Using the parbox. The tabular isn't needed at all. If the linewidth is equal to textwidth, the parbox isn't needed as well.
    – Johannes_B
    Sep 11, 2016 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.