I am trying to align a set of solutions of an equation to previous equations at the position of their equal signs. Next to the set equations is a bracket that goes over both lines. The code I already have is equivalent to the following:
\usepackage{amsmath}
\begin{align*}
x^2 & = 1 \\
\Rightarrow \quad \left\{
\begin{array}{r l}
x & = - 1 \\
x & = 1
\end{array}
\right. \\
x & = 1
\end{align*}
Output
Is there or can I set another marker to use for alignment? Are there other equation environments or solutions for the bracket itself that would make this obsolete?
Additionally, is there an option to reduce the space left to the equal signs of the last two equations to 'normal' size (to comparison I copied the last solution inside the normal equation environment)?
Edit: The last problem can be fixed by using aligned instead of array.
Edit 2: Answer provided here!
Related
I'm a LaTeX beginner and would like to have two equations aligned on the equals symbol which is working fine so far. Now, between these two equations I need a line of text. But LaTeX interprets this as a math formula since it's showing a (2) right next to it.
I would like to have it as normal text without a (2) aligned on the far left.
I have already tried things like
\begin{flushleft} line of text \end{flushleft}
but it's not working, maybe because I'm using it inside an {align} environment.
Not sure if it's important to mention but I'm using Overleaf (online LaTeX editor).
\begin{align}
\tilde{w}_{ij} &=
\begin{cases}
w_{ij} & \text{mit $P(i)$}\\
0 & \text{sonst}
\end{cases}\\
\text{This text be on the far left}\\
\tilde{w}_{ij} &= w_{ij} * P(i)
\end{align}
produces this ->
This sounds like a job for \intertext from amsmath:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align}
\tilde{w}_{ij} &=
\begin{cases}
w_{ij} & \text{mit $P(i)$}\\
0 & \text{sonst}
\end{cases}\\
\intertext{This text be on the far left}
\tilde{w}_{ij} &= w_{ij} * P(i)
\end{align}
\end{document}
I am creating a table with mulitrow but I am getting a problem. As far as I understand, this is the form of the multirow:
\multirow{count}{alignment}{content}
where count is the number of rows to merge, alignment is either l, c, r, or *, and content is the content of the row. I tried the following:
\multirow{3}{*}{Framing}
but I am getting a problem. Rather than seeing the word "Framing" in the cell, I see "3*Framing" which gives the indication that the \multirow element isn't working. Any idea?
Also, how is it possible to align a text in a cell vertically?
UPDATE:
I thought the \usepackage{multirow} would solve it, but I still see problems:
First, I can't make vertical alignments.
Second, I get some strange thing with the "Framing" cell. Instead of getting "Framing" aligned to the left, I get one virtual row containing the letter "l" and then after two virtual rows I get the word "Framing"!! It is something like this:
______________
| l |
| |
| Framing |
| |
| |
| |
| |
______________
This is my table for those who asked about it:
\begin{table*}\tiny
\centering
\begin{tabular}{|c|c|c|c|c|p{2in}|}
\hline
Rule & Factor & Best Value & \Delta_t & \Delta_{do} & Comments \\
\hline
% Diagonal Dominance Rule
\multirow{3}{*}{Diagonal Dominance} & Line Angle & 45 & 15 & 30 & The angle between the prominent line of the object and
the diagonal lines \\ % TODO: What object? Make sure it is clear.
& Line Distance & 0 & 0.25 & 1 & The distance, in screen coordinates, from the
prominent line of the object to the diagonal lines. \\ % TODO: Need to define screen coordinates
& Corner Distances & 0 & 0.1 & 0.7 & The distance, in screen coordinates, from the
end of the prominent line of the object to the corners of the screen. \\
\hline
% Framing Rule
\multirow{4}{l}{Framing} & Left Distance & 0 & ${Frame Width}*5\%$ & ${Frame Width}*25\%$ & The distance between the
left side of the frame covering the object and the left or the right side of the intended frame, whichever closer. \\
& Right Distance & 0 & ${Frame Width}*5\%$ & ${Frame Width}*25\%$ & The distance between the
right side of the frame covering the object and the left or the right side of the intended frame, whichever closer. \\
& Top Distance & 0 & ${Frame Height}*5\%$ & ${Frame Height}*25\%$ & The distance between the
top side of the frame covering the object and the upper or the lower side of the intended frame, whichever closer. \\
& Bottom Distance & 0 & ${Frame Height}*5\%$ & ${Frame Height}*25\%$ & The distance between the
bottom side of the frame covering the object and the upper or the lower side of the intended frame, whichever closer. \\
\hline
\end{tabular}
\caption{The factors of each rule and their parameters.}
\label{table:factors}
\end{table*}
Regards,
Rafid
Did you put \usepackage{multirow} at the beginning of your document?
There are probably good examples out there to follow. I've never used this package but in a short time (seconds) was able to find this PAGE via google. Does following along with that example help you?
Update: after seeing your actual table, I hate to say it but think your spacing glitch is due to the spill over in the "comments" column into multiple lines. I truncated your comments and got this (column 1 is now vertically centered as desired):
\begin{table*}\tiny
\centering
\begin{tabular}{|c|c|c|c|c|p{3cm}|}
\hline
Rule & Factor & Best Value & \Delta_t & \Delta_{do} & Comments \\
\hline
% Diagonal Dominance Rule
\multirow{3}{*}{Diagonal Dominance} & Line Angle & 45 & 15 & 30 & The angle between... \\
& Line Distance & 0 & 0.25 & 1 & The distance, in... \\
& Corner Distances & 0 & 0.1 & 0.7 & The distance, in... \\
\hline
% Framing Rule
\multirow{4}{*}{Framing} & Left Distance & 0 & ${Frame Width}*5\%$ & ${Frame Width}*25\%$ & The distance... \\
& Right Distance & 0 & ${Frame Width}*5\%$ & ${Frame Width}*25\%$ & The distance... \\
& Top Distance & 0 & ${Frame Height}*5\%$ & ${Frame Height}*25\%$ & The distance... \\
& Bottom Distance & 0 & ${Frame Height}*5\%$ & ${Frame Height}*25\%$ & The distance... \\
\hline
\end{tabular}
\caption{The factors of each rule and their parameters.}
\label{table:factors}
\end{table*}
Regarding the {l} argument, I think the link I posted originally is perhaps wrong. LaTeX spits out some errors for me when I try replacing * with l for the \multirow argument. I get this on a test table:
! Missing number, treated as zero.
<to be read again>
l
l.12 \multirow{4}{l}{Batch}
& MM & Min-Min \\
! Illegal unit of measure (pt inserted).
<to be read again>
l
l.12 \multirow{4}{l}{Batch}
& MM & Min-Min \\
After finding THIS, I think the second argument in \multirow is not for an alignment but for a width. The LyX wiki linked says the format is like so:
\multirow{number of rows}{cell width}{cell entry}
We've been assuming that {cell width} was actuall {alignment} and I think the link from earlier makes that confusing. See the note at the LyX wiki about spacing; you can use the following where needed to make it do your bidding:
\renewcommand{\multirowsetup}{\centering}
And replace \centering with \raggedleft or \raggedright where needed. I still think you're going to run into trouble with the multiple lines. I've at least shown that ditching them makes the spacing work as desired... how to force them to be centered with your default example is beyond me, I'm afraid. But perhaps now you know where the problem lies?
I guess if you really, really, really wanted to you could split your sentence up, figure out how many rows it takes, and adjust your \multirow argument accordingly for the increase in rows. Though you'd also probably need a nested multirow structure:
| | item 1, 2 rows | comment 1 line 1 |
| multirow, 4 rows | | comment 1 line 2 (spill over) |
| | item 2, 2 rows | comment 2 line 1 |
| | | comment 2 line 2 (spill over) |
Does that make sense? Column 1 would span all rows for its section, subsequent rows would span the number of rows required by the split up comments, and each line needed by the comments (some take up 3 or 4) would be on their own separate lines and just appear to be continuous. Not sure if the sentence spacing would look weird, though.
Nuff rambling. There's your food for thought.
One Last Update: One last hope way to go about this might be with TikZ tables. Essentially, your nodes are like "cells." Then just put them together and make it look like a table. Perhaps a horrible proposal, but I assure you that you'll have all the flexibility you need with cell spacing and such. Some ideas:
Fancy Tables 1
Fancy Tables 2
Periodic table in TikZ which might give you some insight about how to do this a bit better than the first two?
Wild guess: You're getting undefined control sequence: multirow because you're lacking a \usepackage{multirow} in the preamble?
Yes, you need the multirow package.
\usepackage{multirow}
\begin{document}
\begin{table}
\centering
\begin{tabular}{l||c|r}
Header 1 & Header 2 & Header 3 \\
\multirow{2}{*}{Hello} & stuff & stuff \\
& Body 2 & Body 3
\end{tabular}
\end{table}
\end{document}
EDIT after edits to question: I got two errors:
\multirow{4}{l}{Framing}. I changed to \multirow{4}{*}{Framing}
Delta_t changed to $Delta_t$.
Otherwise, everything seems fine. You may want to ask tex.stackexchange.com, too.
I got a problem with tables in LaTeX. I am using a pre-defined format from a conference, which makes a page consists of two columns. My table is too wide to be contained in one column, so it goes to the second column of the page and overlaps with text!
Why is LaTeX allowing this?
Is it possible in the current format, to make the table a block, so that it uses two columns, and the text in the other column dragged down a bit?
Any other suggestion?
This is my code:
\begin{table}
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Rule & Factor & Best Value & Delta_t & Delta_{do} & Comments \\
\hline
\multirow{3}{c}{Diagonal Dominance} & Line Angle & 45 & 15 & 30 & The angle between the prominent line of the object and
the diagonal lines \\ % TODO: What object? Make sure it is clear.
& Line Distance & 0 & 0.25 & 1 & The distance, in screen coordinates, from the
prominent line of the object to the diagonal lines. \\ % TODO: Need to define screen coordinates
& Corner Distances & 0 & 0.1 & 0.7 & The distance, in screen coordinates, from the
end of the prominent line of the object to the corners of the screen. \\
\hline
\end{tabular}
\caption{The factors of each rule and their parameters.}
\label{table:factors}
\end{table}
Thank you in advance for your help.
Regards,
Rafid
Generally, the starred version of floating environments are used to tell LaTeX to span two columns. So, something like:
\begin{table*}
% Table contents
\end{table*}
The same can be done with figures.
In place of tabular, use tabularx, for example:
\begin{tabularx}{\textwidth}{|c|c|c|c|c|X|}
Sorry, #Rafid, I normally use memoir, which includes it, so I forgot this bit:
\usepackage{tabularx}
I have this equation and it's quite big (basically a FDM one) but it aligns with the text and then continues out on the right side to the nothingness. I've tried stuff like \begin{center} and \hspace*{-2.5cm} but to no avail. I want it to use the whole line not just from the left-margin and out to the right.
How do I do it and do I need to install some special package for it?
I use the \[ instead of the displaymath like this
\[
Equation arrays here
\]
The code
\[
\left(
\begin{array}{cccccc}
-(2\kappa+\frac{hV\rho}{2}) & (\frac{hV\rho}{2}-\kappa) & 0 & \cdots & 0 \\
-\kappa & -(2\kappa+\frac{hV\rho}{2}) & (\frac{hV\rho}{2}-\kappa) & 0 & \cdots \\
0 & -\kappa & -(2\kappa+\frac{hV\rho}{2}) & (\frac{hV\rho}{2}-\kappa) & 0 & \cdots \\
\vdots & 0 & \ddots & \vdots \\
\vdots & \vdots & \vdots & -\kappa & -(2\kappa+\frac{hV\rho}{2}) & (\frac{hV\rho}{2}-\kappa) \\
0 & \vdots & \vdots & 0 & \kappa - \frac{2h\kappa_{v}}{\kappa}(\frac{hv\rho}{2} - \kappa) & -2\kappa \\
\end{array}
\right)
\left(
\begin{array}{c}
T_{1} \\
T_{2} \\
\vdots \\
T_{n} \\
\end{array}
\right)
=
\left(
\begin{array}{c}
Q(0) + \kappa T_{0} \\
Q(h) \\
Q(2h) \\
\vdots \\
Q((n-1)h) \\
2\frac{\kappa_{v}}{\kappa_{v}}T_{out} \\
\end{array}
\right)
\]
The \[ \] delimiters are intended for single-line equations. In basic LaTeX you can use the eqnarray environment to make a multi-line equations, or you can use the multline environment from the amsmath package. The eqnarray environment lets you use \\ for line breaks but if you want the equation to be numbered, you also need to use the \nonumber command on all lines but one to prevent the numbering of all lines. The multline environment is intended for a single equation so it always produces just one equation number too.
EDIT: This isn't what I would do habitually, but since your equation does seem to fit on a single line, here's the code I've used to get whole-line spanning things:
\newenvironment{widefig}[1][1in]{%
\begin{list}{}{\setlength{\itemindent}{-#1}%
\setlength{\leftmargin}{0pt}%
\setlength{\rightmargin}{0pt}}\item
}{%
\end{list}
}
Like the environment name suggests, I wrote it for figures that are too wide to fit inside the margins, so this allows controlling the left margin and permits a figure to be centered on the whole line.
How I modified your example was to wrap it inside a \begin{widefig}[1.5in]-\end{widefig} pair, added
\relpenalty=10000
\binoppenalty=10000
after the \begin{widefig} line to prohibit line breaking inside the formula, and changed the \[\] into \(\) because the widefig environment only works for inline, not display. You might also need to fiddle a bit with the amount of space given on the \begin line to make the equation properly centered.
I don't believe this is very good typesetting style, though, so you'll want to be very careful about using it, and preferably try to fit things inside the margins. For instance, in this case you could also get rid of a few columns in your first matrix; the usual standard is to have only the first, second, and last, but you probably also want the second-to-last row and column, since the changes in the values for the last row and column is a bit surprising. If you did that, it might fit (but I didn't check).
If you really don't want to break the equation over lines and you don't mind breaking the text width, you could try something like: (untested)
\centerline{$\displaystyle <long equation here>$}
could you add a line-break using \\ ?
Begin centre only aligns things like figures, it won't affect line equations.
You might like to look at the American Mathematical Society guide to their package s
ftp://ftp.ams.org/pub/tex/doc/amsmath/amsldoc.pdf
You could use the eqnarray environment to break equations into multiple lines.
I am trying to prepare a presentation using beamer. I want to have two columns that walkthrough some algebraic manipulations. On the left an explanation of the steps taken, on the right the results.
\documentclass{beamer}
\begin{document}
\begin{frame}[t]
Not in a column
\begin{columns}[t]
\begin{column}{0.5\textwidth}
\only<2->{Some text}
\only<3->{
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
}
\end{column}
\begin{column}{0.5\textwidth}
\only<2->
{
\begin{equation}
E = mc^2
\end{equation}
}
\only<3->
{
\begin{equation}
F = ma
\end{equation}
}
\end{column}
\end{columns}
\end{frame}
\end{document}
And here's some LaTeX which does that (with junk words and equations). When this is compiled the text and maths are not aligned with each other. I wouldn't really expect them to be either as LaTeX will position the text in each column individually, not caring about the other frames.
Does anyone have any ideas on how to achieve the result I am after. I'm not committed to the columns at all, but I am committed to the equation numbers.
The preferred way to get aligned equations with numbering is amsmath package's align environment. See its documentation for help with that. It's quite simple, something like:
\begin{align}
f(x) & = \cos^2 x \\
g(x) & = \sin^2 x
\end{align}
There are a lot of variations trying to cover most conceivable equation alignment needs (again, check out the documentation).
As for your two-column proof format, I'm not as sure about the best way. A quick and dirty way would be to add it as a second column within the environment, something like:
\begin{align}
f(x) & = \cos^2 x & \text{this is the first function} \\
g(x) & = \sin^2 x & \text{this is the second function}
\end{align}
but this is no good for multi-line explanation, and puts the numbering to the right of the text. I'll try and think of a way (one that doesn't involve a lot of custom-defined environments, since surely someone's done this before).
Edit: As a starting point, this [sort of] works:
You can't do any alignment within the align environment (the & confuses things), and there are some vertical alignment issues - the align environment pads itself above and below, and the text in the right-hand cell. Maybe it's heading in a good direction, though!
\begin{tabular}{p{3 in}|l}
\begin{align} f(x) = \sin^2 x \end{align} &
this is the first equation \\
\begin{align} g(x) = \cos^2 x \end{align} &
this is the second equation
\end{tabular}
Usually you'd use amsmath's align or align* environment, but unfortunately it doesn't play nicely with beamer (for fundamental reasons that nobody wants to fix).
The Beamer user guide has a section on this at page 106 that does exactly what you've done. Apparently there's a workaround described in that document too.