1

How can I get LaTeX to apply line breaks in display math mode for a long equation?

I created a table of:

% \usepackage{booktabs} \begin{table}[] \centering \caption{My caption} \label{my-label} \begin{tabular}{@{}|l|l|l|@{}} \toprule & Actual Positive $(y_i=1)$ & Actual Negative $(y_i=0)$ \\ \midrule Predicted Positive $c_i=1$ & $C_{TP_i}=0$ & $C_{FP_i}=r_i+C^m_{FP_i}$ \\ \midrule Predicted Negative $c_i=0$ & $C_{FN_i}=C_{device_i} + C_{marketInvest_i} + C_{usage_i}-Downpayment_i$ & $C_{TN_i}=0$ \\ \bottomrule \end{tabular} \end{table} 

where

$C_{FN_i}=C_{device_i} + C_{marketInvest_i} + C_{usage_i}-Downpayment_i$ 

denotes the equation which is too long.

How can I split it e.g. like

$C_{FN_i}=C_{device_i} + C_{marketInvest_i} + C_{usage_i}-Downpayment_i$ 

When using align in the table

\begin{align*} C_{FN_i}=C_{device_i} &+\\ C_{marketInvest_i} &+\\ C_{usage_i} &-\\ Downpayment_i \end{align} 

the result is a compilation error in latex.

\begin{table}[] \centering \caption{Cost matrix proposed for telecommunication industry.} \label{tbl:tma-costmat} \begin{tabular}{@{}l|l|l@{}} & Actual Positive $(y_i=1)$ & Actual Negative $(y_i=0)$ \\ \midrule Predicted Positive $c_i=1$ & $C_{TP_i}=0$ & $C_{FP_i}=r_i+C^m_{FP_i}$ \\ \midrule Predicted Negative $c_i=0$ & \begin{align*} C_{FN_i}=C_{device_i} &+\\ C_{marketInvest_i} &+\\ C_{usage_i} &-\\ Downpayment_i \end{align} & $C_{TN_i}=0$ \\ \end{tabular} \end{table} 
1
  • Your code is doomed in part because \begin{align*} is paired with \end{align}. Commented Aug 13, 2017 at 18:17

1 Answer 1

1

You can't use an align environment (or an align* environment) the way you propose to do. However, you may use an aligned environment.

enter image description here

\documentclass{article} \usepackage{amsmath,booktabs,array} \usepackage[skip=0.333\baselineskip]{caption} \newcolumntype{L}{>{$}l<{$}} % automatic math mode \newcommand\vn[1]{\mathit{#1}} % "variable name" \begin{document} \begin{table} \centering \caption{Cost matrix proposed for telecommunication industry.} \label{tbl:tma-costmat} \begin{tabular}{@{}lLL@{}} \toprule & \text{Actual Pos.\ }(y_i=1) & \text{Actual Neg.\ }(y_i=0) \\ \midrule Predicted Positive $c_i=1 $ & C_{\vn{TP}_i}=0 & C^{}_{\vn{FP}_i}=r^{}_i+C^m_{\vn{FP}_i} \\ \addlinespace[3mm] Predicted Negative $c_i=0$ & \begin{aligned}[t] C_{\vn{FN}_i}&=C_{\vn{device}_i} \\ &\quad+C_{\vn{marketInvest}_i} \\ &\quad+C_{\vn{usage}_i} \\ &\quad-\vn{Downpayment}_i & \end{aligned} & C_{\vn{TN}_i}=0 \\ \bottomrule \end{tabular} \end{table} \end{document} 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.