1

I'm using latex to format homework for a class. I'm using \section to separate my problems and that is working fine, but when I'd like to answer a question with multiple lines, the spacing becomes impossible. I'm trying to do this at the moment:

\documentclass{article}
\title {hw}
\author {name}
\date {}

\usepackage{tikz}

\begin{document}

\section*{Problem 1} \hspace{1cm} some part of my answer $some equation$ \ \hspace{1cm} second part of my answer $some equation$

I'm not sure if the equations actually matter but I'm new to latex and it might provide more context to my problem. I've tried using \*, \linebreak, \newline, and every time the spacing is incorrect. The only way I've been able to fix it is by making the second \hspace 6mm instead of 1cm which seems bizarre and I'd rather not have to guess and fix spacing every time I use latex. I would appreciate any help or any explanation on how I'm using these commands incorrectly, thank you!

vito
  • 11
  • 1
    you should avoid explicit spacing, delete the hspace and the \\ and just use a blank line between the paragraphs – David Carlisle Apr 04 '22 at 23:11
  • note the first paragraph after a heading is not indented by default you can use the indentfirst package to change that. – David Carlisle Apr 04 '22 at 23:13
  • @DavidCarlisle that works fine, but then there is no indentation, which is what I was going for – vito Apr 04 '22 at 23:13
  • threre will be indenatation by default. You may have set that to 0 in code you haven't shown. It is best to always post a complete small document we can't guess what settings you have elsewhere. – David Carlisle Apr 04 '22 at 23:15
  • @david I have updated my post to include more context – vito Apr 04 '22 at 23:24
  • This seems related to an XY problem, where your concern is about \hspace at the beginning of a line. Instead, you want to just know how to indent or change the margins of a specific portion of your document. A solution to that is provided here: Indenting a whole paragraph (possible duplicate). – Werner Apr 04 '22 at 23:52

2 Answers2

3

As far as I can tell you don't need hspace or \\ here and want a layout like

enter image description here

\documentclass{article}

\usepackage{indentfirst}

\begin{document}

\section*{Problem 1}

some part of my answer $some equation$ some part of my answer $some equation$ some part of my answer $some equation$

second part of my answer $some equation$ some part of my answer $some equation$ some part of my answer $some equation$

\section*{Problem 1}

\begin{itemize}

\item some part of my answer $some equation$ some part of my answer $some equation$ some part of my answer $some equation$

\item second part of my answer $some equation$ some part of my answer $some equation$ some part of my answer $some equation$

\end{itemize}

\section*{Problem 1}

\begin{quote}

some part of my answer $some equation$ some part of my answer $some equation$ some part of my answer $some equation$

second part of my answer $some equation$ some part of my answer $some equation$ some part of my answer $some equation$

\end{quote}

\end{document}

David Carlisle
  • 757,742
  • This does work to indent the first part of each line, but if each part extends to the next line, it will not be in line with the previous line. – vito Apr 04 '22 at 23:27
  • @vito that is how paragraph indentation works, look at any book. If you want to indent the whole text, you don't want indentation you want an an environment like quote or a list that changes the margins. – David Carlisle Apr 04 '22 at 23:30
  • @vito I updated the answer – David Carlisle Apr 04 '22 at 23:38
  • thank you! this is very helpful and is exactly what I needed. – vito Apr 04 '22 at 23:40
-1

I ended up fixing it using the changepage package.

\documentclass{article}

\usepackage{changepage}

\begin{document}

\section*{problem whatever}

\begin{adjustwidth}{1cm}{} first part of answer \ second part of answer \end{adjustwidth}

\end{document}

Werner
  • 603,163
vito
  • 11