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?

link|improve this question

43% accept rate
2  
I think this belongs on Stack Overflow. – jtbandes Jul 24 '09 at 23:45
1  
It's not a clear case. While TeX is turing complete. it's more regarded as a formatting language than a programming language. As this site is for anything (except games) computer related I think it fits well here. – Deleted Jul 25 '09 at 0:56
I'd consider it more of a programming language than something that fits with the term "super user". At the least, you'll probably get more responses on SO. – jtbandes Jul 25 '09 at 2:01
I think three well written answers is quite good (thank you for yours). I realize there might be some other way to do it. But at the moment I'm going for the \hfill suggestion. – Deleted Jul 25 '09 at 10:54
feedback

3 Answers

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.

link|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
show 2 more comments
feedback

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.

link|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
feedback

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.

link|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
feedback

Your Answer

 
or
required, but never shown

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