tags:

views:

1455

answers:

4

I'd like to express the following sentence (source_location is also italic, it's not correctly rendered):

Each entry has a list of tuple: < *source_location*, R/W, trip_counter, occurrence, killed (explained in the later) >

My current workaround for this is:

$ \left\langle
\textit{source\_location}, \textit{R/W}, \textit{trip\_counter},
\textit{occurrence}, \textit{killed} \text{(explained in the later)}
\right\rangle $

I'm using 2-column paper. This < .. > is too long, but no line break because it is a math. How do I automatically (or manually) put line break in such case? It seems that \left\langle and \right\rangle should be in a single math. So, hard to break into multiple maths.

$<$ and $>$ would be an alternative, but I don't like it.

Thanks!

A: 

I'd use the align* environment from AMSmath. Furthermore you could just add "\" to break the lines? Should work in math environments, too. Alternatively you could separate the equations.

wishi
Thanks, but \ and \\ just doesn't work. Separating equations would be an option, but \left\langle and \right\rangle don't allow a separate equation.
minjang
A: 

There seems to be a package that addresses that problem, called breqn. You can try this and let us know (I haven't used that).

Grzegorz Oledzki
breqn is (great) for breaking display equations; the question is about inline maths inside a paragraph.
Will Robertson
You're right. Thanks.
Grzegorz Oledzki
+3  A: 

Why not define a new command:

\newcommand{\tuple}[5]{$\langle$\textit{#1}, \textit{#2}, \textit{#3}, \textit{#4},
   \textit{#5} (explained in the latter)$\rangle$}

Then use \tuple{sourcelocation}{R/W}{tripcounter}{occurrence}{killed}

Rob Hyndman
Thanks Rob, I'll try it also.
minjang
+4  A: 

LaTeX does allow inline maths to break over lines by default, but there are a number of restrictions. Specifically, in your case, using \left...\right puts everything inside a non-breakable math group, so the first step is to replace them with either just plain \langle...\rangle or perhaps \bigl\langle...\bigr\rangle.

However, this still isn't enough to permit linebreaking; usually that's still only allowed after relations or operators, not punctuation such as the comma. (I think this is what's going on anyway; I haven't stopped to look this up.) So you want indicate where allowable line breaks may occur by writing \linebreak[1] after each comma.

Depending how often you have to do this, it may be preferable to write a command to wrap your "tuples" into a nice command. In order to write this in your source:

$ \mytuple{ source\_location, R/W, trip\_counter, occurrence,
    killed\upshape (explained in the later) } $

here's a definition of \mytuple that takes all of the above into account:

\makeatletter
\newcommand\mytuple[1]{%
  \@tempcnta=0
  \bigl\langle
  \@for\@ii:=#1\do{%
    \@insertbreakingcomma
    \textit{\@ii}
  }%
  \bigr\rangle
}
\def\@insertbreakingcomma{%
  \ifnum \@tempcnta = 0 \else\,,\ \linebreak[1] \fi
  \advance\@tempcnta\@ne
}
\makeatother
Will Robertson
Thanks a lot! I'll try it!
minjang
I appreciate your help. It was very useful to me, though I had to select Rob's answer.
minjang
No worries, there's no politics here! Well, he didn't exactly help you put a line break in math mode but his solution works just as well, unless you want more than four items in your tuple :)
Will Robertson