Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use LaTeX, but I only consider myself an average user. I have a special need. If I have a \section{Something} and I would like { something else } on the same vertical line as the section. But aligned right. How would I go about doing that?

share|improve this question

closed as off topic by jtbandes, Simon Sheehan, Renan, 8088, Dave Dec 26 '12 at 7:09

Questions on Super User are expected to relate to computer software or computer hardware within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 3 down vote accepted

If you only want to do this once... don't. Find some other way to present that single bit of information. \hfil[l][l] will work, but it can play havoc with the Table of Contents if you're not careful, and in general you just shouldn't go there.

If you want to add a little bit of extra information to every section title, or even most of them, you're going to have to hack the sectioning commands. You'll probably end up declaring some kind of \customsection[Optional ToC text]{Section title}{Extra information you want on the right side} command. If you can, use the titlesec package; it will save you a lot of time.

share|improve this answer
Interesting, I didn't know about \hfil and \hfilll. When are they used? – jtbandes Jul 24 '09 at 23:34
Usually, when you're making quick and dirty hacks :) They're part of the original TeX and are described in detail in Knuth's TeXBook, but all three are basically the same. The more ls the command has, the more powerful it is: two \hfil on a line will expand to the same size (useful for centering), but throw in one \hfill and it will overpower the \hfils and dominate all the space itself. \hfilll is the nuclear bomb of TeX glue commands, and will crush everything in its path... use it with caution. – kquinn Jul 24 '09 at 23:40
It seems SuperUser botched the formatting on that comment... I'm pretty sure I got it correct, and there's just a bug in the SU code. I'll see if it gets fixed soon, and if not file a bug report on MSO.... – kquinn Jul 24 '09 at 23:41
I guess my question is, what's the point of overpowering the other things like \hfil if they'll completely disappear? You could just not include them. – jtbandes Jul 24 '09 at 23:42
If you're writing in pure TeX and you control everything, there's not much point to them. If you're doing complicated stuff with both standard and custom macros, you'll learn to love them. – kquinn Jul 24 '09 at 23:46

Aha, I found something that may be useful! The titlesec package has a bunch of customizations for titles, including section titles.

Here is a PDF of examples which contains something like this, #8.

share|improve this answer
Yes it looks really useful and I didn't know about it! :-) For my simple needs this time I'll go with the \hfill solution (I'm just writing a resume), but I'm sure it will come in handy in the future. – Deleted Jul 25 '09 at 10:59

Use \hfill .

\section{Something \hfill something else}

Note, that answer your requirement for appearance, I'm not too sure whether you only want "Something" considered as part of the title, because the above solution consider "Something something else" as the title.

share|improve this answer
I was going to post that, but I figured the idea was not to have it be part of the title. Plus, that would probably break the table of contents and other things. – jtbandes Jul 24 '09 at 23:21
You can still define another text to appear in the table of contents, though. Dunno about how hyperref treats this. But that thing breaks pretty easily on nearly everything that is unusual, so I don't expect much anymore. – Joey Jul 24 '09 at 23:33
Thank you! I went with the \hfill solution. I won't be using a TOC in this document (my resume), if I need to I'll probably use the titlesec package. I'm choosing the other answer as my accepted one, as both posts where posted 11 hours ago and the other one is a bit more detailed and has one more vote. It's at times like this I would like the option to pick two accepted answers. Thank you! (And of course I up-vote) – Deleted Jul 25 '09 at 11:01

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