Trying to display an equation spanning multiple columns in table

In summary, the conversation is about a user trying to include equations in a table using the \[...\] command, but encountering errors. The solution is to use the $\displaystyle$ command within the \multicolumn command to properly display the equations.
  • #1
Pencilvester
184
42
TL;DR Summary
I’m trying to make an equation spanning multiple columns in displayed mode, not inline, but I’m getting an error I don’t know how to deal with.
I’ll just paste in all of the packages I’m using and the relevant code. The line in this sample that is giving me errors is line 24. (Errors below)
Code:
\documentclass[10pt]{article}
\pagenumbering{gobble}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{physics}
\usepackage{array}
\usepackage{multirow}
\usepackage[margin=0.5in]{geometry}
\newcommand\Tstrut{\rule{0pt}{2.0ex}}
\newcommand\Bstrut{\rule[-0.7ex]{0pt}{0pt}}
\begin{document}
\phantom{~}\noindent
\renewcommand{\arraystretch}{0}
\begin{table}[t!]
\centering
    \begin{tabular}{|b{3.5in}<{\centering}b{3.5in}<{\centering}|}
    \hline \\
    \multicolumn{2}{|c|}{\textbf{Trigonometric and Exponential}} \Tstrut \Bstrut\\
    \hline \\
% here I have a bunch of displayed equations—2 in each row—using “\[...\] & \[...\] \\” with no issues
% and now I’m trying to use \multicolumn{2}{|c|}{\[eqn\]} \\
    \hline
\end{tabular}
\end{table}
I am getting 2 “missing $ inserted” errors (telling me that for some reason, it wants an inline equation), as well as an error that says “LaTeX error: \begin{tabular} on input line 19 ended by \end{equation*}.” Although this error references line 19, it assigned it to line 24, and I can’t figure out what it is talking about when it says line 19 ended by \end{equation*}.

Can someone tell me what I need to fix in order to get this equation in displayed mode?
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
I'm surprised that it is accepting \[ \] inside a table at all. In the multicolumn, try
\multicolumn{2}{|c|}{$\displaystyle eqn$}
 
  • Like
Likes berkeman
  • #3
DrClaude said:
I'm surprised that it is accepting \[ \] inside a table at all. In the multicolumn, try
\multicolumn{2}{|c|}{$\displaystyle eqn$}
That worked, thanks!
 
  • Like
Likes berkeman

What is the best way to display an equation spanning multiple columns in a table?

The best way to display an equation spanning multiple columns in a table is to use a combination of the <td> and <colspan> HTML elements. The <td> element allows you to create cells within a table, and the <colspan> element allows you to span a cell across multiple columns.

Can I use a mathematical equation in a table cell?

Yes, you can use a mathematical equation in a table cell. You can either type the equation directly into the cell or use HTML to format the equation. You can also use mathematical symbols and formulas in your equation.

How do I format an equation in a table cell?

You can format an equation in a table cell using HTML. You can use the <sup> and <sub> elements to create superscripts and subscripts, and the <math> element to display mathematical formulas. You can also use CSS to further customize the appearance of your equation.

Is it possible to align an equation in a table cell?

Yes, it is possible to align an equation in a table cell. You can use the style attribute and set the text-align property to either left, right, or center to align the equation within the cell. You can also use CSS to align the equation in a specific way, such as using display: flex to center the equation vertically and horizontally within the cell.

Can I use LaTeX to display an equation in a table cell?

Yes, you can use LaTeX to display an equation in a table cell. You can use the <math> element and set the display attribute to inline to render the LaTeX code as an equation in the table cell. You will need to have a LaTeX renderer installed on your computer or use an online tool to convert the LaTeX code to an image before displaying it in the table cell.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
11K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
Back
Top