LyXEquation formatting

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
AnotherDude
Posts: 3
Joined: Sat Dec 03, 2016 10:36 pm

Equation formatting

Post by AnotherDude »

Hey,

I've been having trouble for a while making the attached equation look normal.
I've read about different align environments but couldn't get any of them to work well (since a bunch need actual code which i'm not familiar with)
The main problems with what I've done is that awkward minus sign and not enough spacing between the lines.
Anyway, i'd be grateful for any help on how to do once and for all.

Thanks!
Capture.PNG
Capture.PNG (36.25 KiB) Viewed 4313 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Equation formatting

Post by Stefan Kottwitz »

Welcome to the forum!

Hard to say with just a screenshot. Could you post the pdfLaTeX export, so we can see source code?

Stefan
LaTeX.org admin
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Equation formatting

Post by scottkosty »

In addition to the PDF output, the actual .lyx file itself might be helpful. For tips on how to create a minimal example, see https://wiki.lyx.org/FAQ/MinimalExample.
AnotherDude
Posts: 3
Joined: Sat Dec 03, 2016 10:36 pm

Equation formatting

Post by AnotherDude »

Thanks for the reply!
I attached the Lyx file, pdf output and source code.
I also tried to have a single right bracket span two lines which produces an error.
So the pdf is without it and the lyx has what I tried to make that happen.
I don't really know any Latex code either.

Thanks!
Attachments
equationFormat.tex
(4.11 KiB) Downloaded 273 times
equationFormat.lyx
(5.94 KiB) Downloaded 240 times
equationFormat.pdf
(94.77 KiB) Downloaded 148 times
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Equation formatting

Post by scottkosty »

Thanks for posting the example files, but they are not minimal example files: you input another .lyx file, you have preamble code, you use ERT. Are those necessary to reproduce the problem? Please see the link that I specified in my response above.
AnotherDude
Posts: 3
Joined: Sat Dec 03, 2016 10:36 pm

Equation formatting

Post by AnotherDude »

They are not necessary, but I don't really have a specific problem. It's more on how to do something, so It's not that something is interfering with something else.
I anyway added the tex without preamble, ERT and the other lyx file. The other lyx file had macros I used so that might explain unknown symbols in
the code.

Thanks!
Attachments
equationFormat.tex
(3.91 KiB) Downloaded 237 times
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Equation formatting

Post by Johannes_B »

I am not quite sure if you are talking about the LyX preview or the final pdf output. I looked at your code, some huge equation.
Your first try was quite good, but you need to cheat a little bit using invisible place holders.

For the second thing (which should be in another thread), you can use rcases from package mathtools.

Code: Select all

%% LyX 2.2.2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm}
\usepackage{enumitem}
\usepackage{mathtools}% improves amsmath
\usepackage{showframe}% Shows the available typeblock

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\newlength{\lyxlabelwidth}      % auxiliary length 

\makeatother

\usepackage{babel}
\begin{document}
\begin{enumerate}
\item This is the ``raw'' equation I need to set up
\begin{align*}
F_{X}\left(s\right)-F_{X}\left(s-1\right) & =\P\left\{ \omega\in\Omega:X\left(\omega\right)\leq s\right\} -\P\left\{ \omega\in\Omega:X\left(\omega\right)\leq s-1\right\} \underset{_{\text{like previsously}}}{=}\P{\left\{ \omega\in\Omega:X\left(\omega\right)=1\right\} \cup\left\{ \omega\in\Omega:X\left(\omega\right)=2\right\} \cup\dots\cup\left\{ \omega\in\Omega:X\left(\omega\right)=s\right\} }-\\
 & \P{\left\{ \omega\in\Omega:X\left(\omega\right)=1\right\} \cup\left\{ \omega\in\Omega:X\left(\omega\right)=2\right\} \cup\dots\cup\left\{ \omega\in\Omega:X\left(\omega\right)=s-1\right\} }=\P\left\{ \omega\in\Omega:X\left(\omega\right)=1\right\} +\P\left\{ \omega\in\Omega:X\left(\omega\right)=2\right\} +\dots+\P\left\{ \omega\in\Omega:X\left(\omega\right)=s\right\} -\\
 & \P\left\{ \omega\in\Omega:X\left(\omega\right)=1\right\} +\P\left\{ \omega\in\Omega:X\left(\omega\right)=2\right\} +\dots+\P\left\{ \omega\in\Omega:X\left(\omega\right)=s-1\right\} =\P\left\{ \omega\in\Omega:X\left(\omega\right)=s\right\} =f_{X}\left(s\right)
\end{align*}

\begin{align*}
F\left(s\right)-F_{X}\left(s-1\right) 
 &=\P{\left\{ \omega\in\Omega:X\left(\omega\right)=1\right\} \cup\left\{ \omega\in\Omega:X\left(\omega\right)=2\right\} \cup\dots\cup\left\{ \omega\in\Omega:X\left(\omega\right)=s\right\} }-\\
 &\phantom{=~}-(\P{\left\{ \omega\in\Omega:X\left(\omega\right)=1\right\} \cup\left\{ \omega\in\Omega:X\left(\omega\right)=2\right\} \cup\dots\cup\left\{ \omega\in\Omega:X\left(\omega\right)=s-1\right\} })=\} \\
&=\P\left\{ \omega\in\Omega:X\left(\omega\right)=1\right\} +\P\left\{ \omega\in\Omega:X\left(\omega\right)=2\right\} +\dots+\P\left\{ \omega\in\Omega:X\left(\omega\right)=s\right\} - \\
&\phantom{=~}-(\P\left\{ \omega\in\Omega:X\left(\omega\right)=1\right\} +\P\left\{ \omega\in\Omega:X\left(\omega\right)=2\right\} +\dots+\P\left\{ \omega\in\Omega:X\left(\omega\right)=s-1\right\} )= \\
&=\P\left\{ \omega\in\Omega:X\left(\omega\right)=s\right\} =f_{X}\left(s\right)
\end{align*}
\item Here I'm trying to make a curly bracket span two lines with no success.
The attached pdf is without this since it doesn't compiles
\[
	\begin{rcases} \frac{3}{234} & \text{if } x=0\\
		\mathit{something} & \text{if some other thing}
\end{rcases}
\]
\end{enumerate}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Equation formatting

Post by scottkosty »

AnotherDude, note that in LyX phantom can be accessed either by just typing [backslash]phantom[space] or with the "Math spacings" icon on the math toolbar (the red boat icon thing). You can read more about phantom in LyX's Math manual. I recommend taking a look.
Post Reply