4

This is my first time giving LaTeX a try, and I decided to have my go at it with my week's math homework. Though most of the document could probably be done in a more efficient manner, I've gone about 30 lines without too much of a hitch.

My problem arises in line 30, where I wanted to format a line so that I had text flushed left and right on the same line, which I was able to do after some googling. However, the paragraphs following my \raggedleft text will not indent, no matter what I try. Here is the code, can somebody help me out?

    \documentclass[11pt]{article}
   \usepackage{framed}
   \usepackage{fullpage}
   \usepackage{amsmath}
   \author{Author Name Here}
   \title{Quiz 7 Makeup}
   \date{March 11, 2014}

   \begin{document}
   % generates the title
   \maketitle
  Instructions: Find general solutions of the differential equations for the following problems found in section 1.6:\\
  2) $xy^2+3y^2 -x^2y'=0$

  \underline{Solution:} $xy^2+3y^2 -x^2y'=0 \Rightarrow xy^2+3y^2=x^2y' \equiv y^2(3+x)=x^2y'$

  $LHS=\dfrac{x+3}{x^2}=\dfrac{y'}{y^2}=RHS$

  $LHS= \displaystyle{\int \frac{x+3}{x^2}}\,dx\ = \int \displaystyle{\frac{1}{x}+\frac{3}{x^2} \,dx} = \ln(x) +-3x^{-1} $

  $RHS= \displaystyle{\int \frac{y'}{y^2} \,dx = -y^{-1}}$

  Since $LHS=RHS$, we find the general solution to be $$y=\dfrac{1}{3x^{-1}-\ln{x}} .$$      \\
  8) $x^{2}y'=xy+x^{2}e^{y/x}$                        

  \underline{Solution:}  $x^{2}y'=xy+x^{2}e^{y/x} \equiv y'= \dfrac{y}{x}+e^{y/x} \Rightarrow y'-\dfrac{y}{x}=e^{y/x}$

  \indent\indent Integrating Factor: $e^{\int \frac{-1}{x}\,dx} = e^{-\ln{x}}=e^{\ln{x^{-1}}}=\dfrac{1}{x}$

  \indent$\frac{d}{dy}[y(x)]=e^{y/x}(\dfrac{1}{x}) \Rightarrow yx = \int \dfrac{1}{x}e^{y/x}\,dy = $  \hfill\raggedleft\framebox{Let $u =\dfrac{y}{x}$ so that $du= \dfrac{1}{x} \,dy$} \raggedright \flushleft
  \indent What works?

  What works?\\
  \indent What works?!

  \indent What works?
   \end{document}

As a side question, I would appreciate any tips if ya'll see some inefficiencies in my document. I'm particularly wondering about the sections below the math problems where I would like to have them indented; my solution was to make each new line a new paragraph, giving it another indentation. Is there a command I could use to to just indent a whole block of text?

Thank you! I greatly appreciate any help and advice.

Roy
  • 41
  • You might try to remove extraneous items from your example code so that people answering your question can easily see the parts that aren't doing what you want. – cslstr Mar 12 '14 at 01:03

1 Answers1

2

I fixed some of the main issues, although I'm not sure of the layout you wanted.

\raggedright affects paragraphs at a time, and stays in force until the end of the group, or end of the document, so you didn't want that there. Similarly \displaystyle is a (rarely used) declaration that affects the entire math list, it does not take an {} argument. It is better to use a display math environment (\[ \] or alignetc). I used a list environment for your questions which sets the paragraph indentation to 0 so I used the enumitem package to set it back to something larger. Don't use the math italic font for multi-letter identifiers, so I switched it \mathit (which is text italic, in math mode). Try to avoid using \\ outside its use in alignments.

  \documentclass[11pt]{article}
   \usepackage{framed}
   \usepackage{fullpage}
   \usepackage{amsmath,enumitem}
   \author{Author Name Here}
   \title{Quiz 7 Makeup}
   \date{March 11, 2014}

   \begin{document}
   % generates the title
   \maketitle
  Instructions: Find general solutions of the differential equations for the following problems found in section 1.6:

\begin{enumerate}[listparindent=1cm]
 \item[2] $xy^2+3y^2 -x^2y'=0$

  \textbf{Solution:}
  \begin{gather*}
   xy^2+3y^2 -x^2y'=0 \Rightarrow xy^2+3y^2=x^2y' \equiv y^2(3+x)=x^2y'\\
  \mathit{LHS}=\frac{x+3}{x^2}=\frac{y'}{y^2}=\mathit{RHS}\\
  \mathit{LHS}= \int \frac{x+3}{x^2}\,dx = \int \frac{1}{x}+\frac{3}{x^2} \,dx = \ln(x) +-3x^{-1} \\
  \mathit{RHS}= \int \frac{y'}{y^2} \,dx = -y^{-1}
\end{gather*}

  Since $\mathit{LHS}=\mathit{RHS}$, we find the general solution to be
  \[y=\frac{1}{3x^{-1}-\ln{x}} .\]

  \item[8] $x^{2}y'=xy+x^{2}e^{y/x}$                        

  \textbf{Solution:} 
\[x^{2}y'=xy+x^{2}e^{y/x} \equiv y'= \dfrac{y}{x}+e^{y/x} \Rightarrow y'-\dfrac{y}{x}=e^{y/x}\]

  Integrating Factor:
\[e^{\int \frac{-1}{x}\,dx} = e^{-\ln{x}}=e^{\ln{x^{-1}}}=\dfrac{1}{x}\]

  $\frac{d}{dy}[y(x)]=e^{y/x}(\dfrac{1}{x}) \Rightarrow yx = \int \dfrac{1}{x}e^{y/x}\,dy = $ 
 \hfill 
 \framebox{Let $u =\dfrac{y}{x}$ so that $du= \dfrac{1}{x} \,dy$}


What works?

  What works?   What works?! this is an indent at start of para adding more text so it shows.
this is an indent at start of para adding more text so it shows.


  What works?
\end{enumerate}
   \end{document}
David Carlisle
  • 757,742
  • Why shouldn't you use maths italic for multi-letter identifiers? Is this a spacing/kerning issue? – cfr Mar 12 '14 at 01:37
  • @cfr Yes, kerning — compare $LHS = \mathit{LHS}$. Or much worse, $diff$ = \mathit{diff}$. (Unless you're using unicode-math, which is unfortunately a bit fuzzy on these points still.) – Will Robertson Mar 12 '14 at 02:12
  • @WillRobertson Thank you. I was just curious whether it was related to something somebody argued the other day but, thankfully, not. (That was about whether it was correct to write $xy$ which I see DC does now I look. Good!) – cfr Mar 12 '14 at 02:46
  • 2
    @cfr mostly kerning but also (in some font setups) letter shapes . Either way the point is that the font is set up so that $abc$ is designed not to look like the word abc but rather the product of the three variables a, b and c. Coversely \mathit{abc} is designed to look like a single multi-letter identifier. – David Carlisle Mar 12 '14 at 09:14
  • Thanks. I mainly asked because somebody claimed that I ought not to write $xy$ for the product of x and y but should be writing $x y$ which didn't fit the usage in the book I learnt LaTeX from or examples I'd seen. (I don't write much maths but I would like to make sure that the little I do write is correct! Logic is a bit different.) – cfr Mar 12 '14 at 18:35
  • @cfr all spaces are ignored in math mode, so there is absolutely no difference between $xy$ and $x y$ – David Carlisle Mar 12 '14 at 20:12
  • That's what I always thought. It was the discussion in the comments at http://tex.stackexchange.com/q/162823/39222 which confused me. – cfr Mar 12 '14 at 22:07
  • Can you clarify what you mean by "It is better to use a display math environment ([ ] or align etc)"? What I was trying to get out of \displaystyle command is a larger looking fraction/integral. I'm not sure how the syntax of [ ] works or how to use align to adjust it.

    I'll definitely have to look into how list environments and enumerate.

    As well, I do appreciate the stylistic approach of using {gather}, I'll make sure to look into that. Just to be clear, does does the gather command turn all of it's argument into a math environment?

    – Roy Mar 13 '14 at 06:26
  • You were using inline math $a=b$ and then trying to force it to use displaystyle. That is almost always wrong. You should use a display math environment \[a=b\] or \begin{align}a&=b\end{align} or \begin{equation}a=b\end{equation} If you do use \displaystyle you do not use the syntax that you used \displaystyle{a=b} is wrong you should not have the {}. Similarly you would not have had to use \dfrac to force display style had you used the. correct environment to start the math. – David Carlisle Mar 13 '14 at 09:25
  • @cfr there Adeel meant that he wished TeX treated xy differently to x y as he wished that multiletter identifiers like xy (or sin were automatically roman) But they are not:-) – David Carlisle Mar 13 '14 at 09:29
  • Ah. OK. I see. Thank you. Now I'm less confused (about this anyway). – cfr Mar 13 '14 at 12:24