3

I have a command written as follows:

\documentclass[12pt]{book}
\usepackage{setspace}

\newcommand{\statshyp}[2]{\noindent \hangindent=1cm \hangafter=0 
\begin{singlespace*}
\textbf{#1}: \emph{#2}
\end{singlespace*}
}

Unfortunately, changing the line spacing just within the new command doesn't work. The intention is to create a macro which allows me to create identically formatted single-spaced hypotheses in a generally doublespaced document. Is there a way to do this? I found one other person asking a similar question but the answers given to him provided a way for him to get what he needed without using the spacing commands at all.

1

2 Answers 2

2

This might be something near to what you want; but the result is not pretty (nothing with very large interline space can be).

I don't think that a length such as 1cm is good: it doesn't mix with the other parameters. Perhaps more space would be needed around the single spaced insertion.

\documentclass[12pt]{book}
\usepackage{setspace,lipsum,changepage}

\makeatletter
\renewenvironment{singlespace*}
  {\setstretch {\setspace@singlespace}%
   \vskip -\baselineskip}
  {\vskip -.25\baselineskip}
\makeatother

\newcommand{\statshyp}[2]{%
  \begin{singlespace*}
  \begin{adjustwidth}{1cm}{0pt}
  \noindent\textbf{#1}: \emph{#2} \par
  \end{adjustwidth}
  \end{singlespace*}
}

\onehalfspacing
\begin{document}

\lipsum[2]

\statshyp{Some}{I don't know what to say, but I'm
trying to keep it very long so that it wraps and
the paragraph will show the effect of the parameters.}

\lipsum[3]

\end{document}

enter image description here

2
  • Thank you. Not to be greedy, but is there a way to do it without redefining singlespace? I would like to use the command normally elsewhere ... I promise to contribute back to the board later, answering questions that I can in gratitude for the questions answered.
    – Ennis
    May 6, 2013 at 1:03
  • @Ennis Alternating single with double spacing needs careful setting of the parameters; the attempt made by setspace with the singlespacing* environment fails to give symmetric spaces, so adjustments are necessary. Of course the best is not using double spacing.
    – egreg
    May 6, 2013 at 8:47
0
\documentclass{article}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage{verbatimbox}
\doublespacing
\newcommand\statshyp[2]{%
\noindent\parbox{\textwidth}{\singlespacing\textbf{#1}: \emph{#2}}
~\par%
}
\begin{document}
\lipsum[1]
\statshyp{Hypothesis}{This is my hypothesis:  that I can insert
single-spaced stuff.  This line must be long enough to extend over
multiple lines.  This should be enough for the test}
\lipsum[2]
\end{document}

enter image description here

You must log in to answer this question.

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