Prevent horizontal text stretch in part of text
Here, I keep the bolded property label from stretching by putting it in an \mbox
, including the following blank space(s). Then, I invoke \ignorespaces
after \itshape
to squeeze out that extra liberty that LaTeX was taking in adding a space. I make sure lines of the environment definition end in %
to fend off extra, unwanted, space tokens.
\documentclass[letterpaper,12pt]{report}
\usepackage{amsmath}
\setlength{\parindent}{0pt}
% Creating a counter for the Property environment
\newcounter{ctrProperty}
% Defining a custom Property environment
\newenvironment{myProperty}{%
\refstepcounter{ctrProperty}%
\mbox{\textbf{Property \thectrProperty} ~}%
\itshape\ignorespaces%
}{\par}
\hyphenation{supercalifragilisticexpialidocious}
\begin{document}
\begin{myProperty}
A little bit of text.
\end{myProperty}
\begin{myProperty}
\sloppy More text that causes a stretch because it ends in a word supercalifragilisticexpialidocious
\end{myProperty}
\end{document}
For a differnt approach, as I mentioned in a comment, one could alternatively typeset the text in \raggedright
.
The simple space you insert gets interpreted by TeX as a normal space, ie it has a definite amount of stretchability and shrinkability (alongside its natural width). You could try and insert manually a hspace
amount; I opted for 0.4em
but you can choose which one looks the best for you ie:
\documentclass[letterpaper,12pt]{report}
\usepackage{amsmath}
\setlength{\parindent}{0pt}
% Creating a counter for the Property environment
\newcounter{ctrProperty}
% Defining a custom Property environment
\newenvironment{myProperty}{%
\refstepcounter{ctrProperty}%
\textbf{Property\hspace{.4em}\thectrProperty }\itshape%
}{\par}
\hyphenation{supercalifragilisticexpialidocious}
\begin{document}
\begin{myProperty}
A little bit of text.
\end{myProperty}
\begin{myProperty}
More text that causes a bit of a stretch because it ends in a word supercalifragilisticexpialidocious
\end{myProperty}
\end{document}
Thanks to @egreg for busting some spurious spaces
You might consider using enumitem
and the enumerate environment for this, instead? Then you're guaranteed to have proper spacings for the labels. And the item body starts from the same line (the 'A' and 'M' as in your question).
\documentclass[letterpaper,12pt]{report}
\usepackage[showframe]{geometry} % not required in main file
\usepackage{enumitem}
\setlength{\parindent}{0pt}
\hyphenation{supercalifragilisticexpialidocious}
\newlist{myProperty}{enumerate}{1}
\setlist[myProperty]{before=\itshape,label=Property \arabic*, font=\normalfont\textbf, noitemsep, wide, resume}
\begin{document}
\begin{myProperty}
\item A little bit of text.
\item More text that no longer causes a stretch because it ends in a word supercalifragilisticexpialidocious
\end{myProperty}
Then some intermediate text.
\begin{myProperty}
\item A little bit of text.
\item More text that no longer causes a stretch because it ends in a word supercalifragilisticexpialidocious
\end{myProperty}
\end{document}