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.

  • 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 1:03
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}
| improve this answer | |
  • Why shouldn't you use maths italic for multi-letter identifiers? Is this a spacing/kerning issue? – cfr Mar 12 '14 at 1: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 2: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 2: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 9: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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.