Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

My inline equation falls outside the margin. I was wondering if there is any solution for that? Here is the MWE:

\documentclass[12pt,letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage{kpfonts}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\begin{document}
where the first equality in \ref{inequality} follows from $\lceil\frac{s}%
{t}\rceil=\lfloor\frac{s+t-1}{t}\rfloor$ for integer $s$ and $t$ and the
inequality follows from the feasibility condition. We also assume that the
item can be ordered at any day of the week and these orders arrive instantly.
For each day $t\in W$ define $p_{x,t,n,j} \left(
\text{for all }x=0,\cdots,u_{j}\text{ }\text{and }
n\in N_{x,t,j}
\right)$ to be the joint probability of
\end{document}
share|improve this question
1  
Stuff enclosed in \left...\right can't be broken, so you're giving the paragraph formatter an impossible problem to solve. Either (a) use a displayed formula or (b) leave out \left and \right or (c) use \raggedright. –  Stephan Lehmke Nov 20 '12 at 6:13
1  
… (d) without braces at all, (dd) $p_{x,t,n,j}$ for all $x=0,\cdots,u_{j}$ and $n\in N_{x,t,j}$, (e) combining (dd) and text braces. (Note, that your \left( hasn't a space preceding it.) –  Qrrbrbirlbel Nov 20 '12 at 6:30
add comment

2 Answers

up vote 4 down vote accepted

One solution is to use the \bracr macro as below:

enter image description here

or as Stephan Lehmke suggested, use display math:

enter image description here

References:

CodeL

\documentclass[12pt,letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage{kpfonts}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm,showframe]{geometry}

\makeatletter
\def\@BracContents{} % default (used by \suchthat)
\newcommand{\BracKern}{\kern-\nulldelimiterspace}
\newcommand{\@Brac}[3]{% #1,#3 = left/right bracket type
    \ensuremath{%
        \begingroup\def\@BracContents{#2}%
        \mathopen{\left#1\vphantom{#2}\BracKern\right.}% left bracket
        #2%  content
        \mathclose{\left.\BracKern\vphantom{#2}\right#3}% right bracket
        \endgroup%
    }%
}
\newcommand{\bracr}[1]{\@Brac{(}{#1}{)}}%
\makeatother

\begin{document}
\section{Use macro:}
where the first equality in \ref{inequality} follows from $\lceil\frac{s}%
{t}\rceil=\lfloor\frac{s+t-1}{t}\rfloor$ for integer $s$ and $t$ and the
inequality follows from the feasibility condition. We also assume that the
item can be ordered at any day of the week and these orders arrive instantly.
For each day $t\in W$ define $p_{x,t,n,j} \bracr{
\text{for all }x=0,\cdots,u_{j}\text{ }\text{and }
n\in N_{x,t,j}
}$ to be the joint probability of

\section{Display Math:}
where the first equality in \ref{inequality} follows from $\lceil\frac{s}%
{t}\rceil=\lfloor\frac{s+t-1}{t}\rfloor$ for integer $s$ and $t$ and the
inequality follows from the feasibility condition. We also assume that the
item can be ordered at any day of the week and these orders arrive instantly.
For each day $t\in W$ define 
\[
p_{x,t,n,j} \left(
\text{for all }x=0,\cdots,u_{j}\text{ }\text{and }
n\in N_{x,t,j}
\right)
\]
to be the joint probability of
\end{document}
share|improve this answer
    
Thanks a lot; very insightful as always! This works. –  N Nik Nov 20 '12 at 17:31
    
For future reference: I used solution suggested by @egreg (solution). But for situations where egreg's solution don't apply, solution suggested by @ Peter works perfectly fine. Actually Peter's solution is more general. –  N Nik Nov 20 '12 at 17:34
add comment

The way you input the formula is questionable. Here is how I'd type it:

For each day $t\in W$ define $p_{x,t,n,j}$ (for all $x=0$,~\dots, $u_{j}$
and $n\in N_{x,t,j}$) to be the joint probability of

Those parentheses are not math and shouldn't be larger than usual. You are simply stating a side condition, just use alternating text and math.

share|improve this answer
    
Very good point @egreg. I fixed it. –  N Nik Nov 20 '12 at 17:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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