0

I have been adding a new line with trial and error, otherwise some sentences are much too long and the text looks ridiculous.

I did not add new lines on purpose and you'll see that a newline is inserted in places. My intention is not to have this text all in 1 paragraph, thought I'd get answers instead of tediously adding new lines to my text so the length of each line is equal,

With newlines I can keep the length of the sentences the same through trial and error, this feels like a waste if time and there's bound to to be a solution, I really dislike how long the lines can get.

Desired behavior:

Automatically take a new line after a specifc number of characters, the default line length is much too long for my taste, I'd like to keep all lines the same length.

Example and code:

\def\pl{\ +\ }
\def\eq{\ =\ }
\def\cd{\ \cdot\ }

\def\pr#1{\begin{flushleft}#1\end{flushleft}}
\def\hed#1{\textbf{\pr{#1}}}

% Coming from a coding background,
% I'm used to having a space before and after operators.
% the normal operator spacing annoys me.

% l just think it looks better

\begin{document}

\hed{
  Notes on moles and molar mass:
}

\pr{
Molar mass is different for each atom/compound/molecule etc, it can be calculated can calculate it given you know the calculate the weight of 1 atom then (add up all protons, neytrons and electrons) then multiply it by $N_A[Avogadro's\ number] \eq 6.022 \cd 10^{23}$.
There's no reason to calculate this, The vast majority will look at some kind of data book m.
1 molar mass contains $6.022 \cd 10^{23}$ particles.
The molar mass of each element, compound, molecule etc varies as they have less or more neutrons protons and electrons.
Molar mass ensures that when you react different things the same number of particles will react. 1 mole is 1 molar mass.
}

\end{document}

enter image description here

3
  • 1
    by default tex will justify paragraphs making all lines equal length and straight left and right margin. But you are specifying flushleft which is the environment form of \raggedright so you disable justification. I would remove all the definitions and use \section*{Notes on moles and molar mass} Aug 13, 2023 at 8:58
  • I see but I feel the number of characters in the line is way too long
    – Nickotine
    Aug 13, 2023 at 9:29
  • your answer is perfect for my needs
    – Nickotine
    Aug 13, 2023 at 9:29

1 Answer 1

2

I think you want something like

enter image description here

\documentclass{article}
\usepackage{parskip,amsmath}

% spacy math
%\thinmuskip=3mu
%\medmuskip=4mu plus 2mu minus 4mu
%\thickmuskip=5mu plus 5mu

\thinmuskip=5mu
\medmuskip=9mu plus 2mu minus 6mu
\thickmuskip=12mu plus 5mu minus 5mu

\begin{document}


\subsection*{Notes on moles and molar mass:}


Molar mass is different for each atom/compound/molecule etc, it can be
calculated can calculate it given you know the calculate the weight of
1 atom then (add up all protons, neytrons and electrons) then multiply
it by \[N_A  \textit{[Avogadro's number]} - 6.022 \cdot 10^{23}.\]  There's no
reason to calculate this, The vast majority will look at some kind of
data book m.  1 molar mass contains $6.022 \cdot 10^{23}$ particles.
The molar mass of each element, compound, molecule etc varies as they
have less or more neutrons protons and electrons.  Molar mass ensures
that when you react different things the same number of particles will
react. 1 mole is 1 molar mass.

\end{document}

For the line width it is not clear if you mean for the whole document, eg

enter image description here

\documentclass[twocolumn]{article}
\usepackage{parskip,amsmath}

% spacy math
%\thinmuskip=3mu
%\medmuskip=4mu plus 2mu minus 4mu
%\thickmuskip=5mu plus 5mu

\thinmuskip=5mu
\medmuskip=9mu plus 2mu minus 6mu
\thickmuskip=12mu plus 5mu minus 5mu

\begin{document}


\subsection*{Notes on moles and molar mass:}


Molar mass is different for each atom\slash compound\slash molecule etc, it can be
calculated can calculate it given you know the calculate the weight of
1 atom then (add up all protons, neytrons and electrons) then multiply
it by \[N_A  \textit{[Avogadro's number]} - 6.022 \cdot 10^{23}.\]  There's no
reason to calculate this, The vast majority will look at some kind of
data book m.  1 molar mass contains $6.022 \cdot 10^{23}$ particles.
The molar mass of each element, compound, molecule etc varies as they
have less or more neutrons protons and electrons.  Molar mass ensures
that when you react different things the same number of particles will
react. 1 mole is 1 molar mass.


\end{document}

or just a region:

enter image description here

\documentclass{article}
\usepackage{parskip,amsmath}

% spacy math
%\thinmuskip=3mu
%\medmuskip=4mu plus 2mu minus 4mu
%\thickmuskip=5mu plus 5mu

\thinmuskip=5mu
\medmuskip=9mu plus 2mu minus 6mu
\thickmuskip=12mu plus 5mu minus 5mu

\begin{document}


\subsection*{Notes on moles and molar mass:}


Molar mass is different for each atom\slash compound\slash molecule etc, it can be
calculated can calculate it given you know the calculate the weight of
1 atom then (add up all protons, neytrons and electrons) then multiply
it by \[N_A  \textit{[Avogadro's number]} - 6.022 \cdot 10^{23}.\]  There's no
reason to calculate this, The vast majority will look at some kind of
data book m.  1 molar mass contains $6.022 \cdot 10^{23}$ particles.
The molar mass of each element, compound, molecule etc varies as they
have less or more neutrons protons and electrons.  Molar mass ensures
that when you react different things the same number of particles will
react. 1 mole is 1 molar mass.

\begin{minipage}{0.75\linewidth}

\subsection*{Notes on moles and molar mass:}


Molar mass is different for each atom\slash compound\slash molecule etc, it can be
calculated can calculate it given you know the calculate the weight of
1 atom then (add up all protons, neytrons and electrons) then multiply
it by \[N_A  \textit{[Avogadro's number]} - 6.022 \cdot 10^{23}.\]  There's no
reason to calculate this, The vast majority will look at some kind of
data book m.  1 molar mass contains $6.022 \cdot 10^{23}$ particles.
The molar mass of each element, compound, molecule etc varies as they
have less or more neutrons protons and electrons.  Molar mass ensures
that when you react different things the same number of particles will
react. 1 mole is 1 molar mass.
  
\end{minipage}

\begin{minipage}{0.5\linewidth}

\subsection*{Notes on moles and molar mass:}


Molar mass is different for each atom\slash compound\slash molecule etc, it can be
calculated can calculate it given you know the calculate the weight of
1 atom then (add up all protons, neytrons and electrons) then multiply
it by \[N_A  \textit{[Avogadro's number]} - 6.022 \cdot 10^{23}.\]  There's no
reason to calculate this, The vast majority will look at some kind of
data book m.  1 molar mass contains $6.022 \cdot 10^{23}$ particles.
The molar mass of each element, compound, molecule etc varies as they
have less or more neutrons protons and electrons.  Molar mass ensures
that when you react different things the same number of particles will
react. 1 mole is 1 molar mass.
  
\end{minipage}

\end{document}
10
  • This is exactly what I need, thanks as usual for the help :)
    – Nickotine
    Aug 13, 2023 at 9:19
  • yes it works perfectly I think I used section before and It would insert numbers, thanks for gettinf me to the right path
    – Nickotine
    Aug 13, 2023 at 9:27
  • those mudskip macros with that measurements of amu, what are they for? I'm going to write another question I need help with
    – Nickotine
    Aug 13, 2023 at 9:33
  • @Nickotine medmuskip is medium math skip which is the space around infix operators like cdot, I made it bigger rather than use \ everywhere. thickmuskip is the space around relation such as = also made bigger. Aug 13, 2023 at 9:36
  • the spacing for cdot and equals, didn't change, I'd like to add all operators to mudskip, tried with cdot but I couldn't get it working. Can you please take a look at and give your thoughts on my new question? tex.stackexchange.com/questions/693381/…
    – Nickotine
    Aug 13, 2023 at 14:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .