10

I'm new with Latex and trying to get four hypotheses in the following style:

Hypothesis 1 (H1): This is my first hypothesis.

I'm using the amsmath package and the following code:

\newcommand{hyp}{Hypothesis} 

\begin{hyp}

This is my first hypothesis.

\end{hyp}

which gives an output of:

Hypothesis 1: This is my first hypothesis.

I do know how to enumerate the 4 hypotheses but I do not know how to get the H1 to H4 in the brackets.

Null
  • 1,525
Tasia
  • 101
  • 1
    Welcome to TeX.StackExchange! I would like to help you, but I doubt this is the exact code you’re using, I see at least two problems with it (\newcommand should be followed by a command name starting with a backslash, and in this case you would define a command, not an environment). Please post the exact content of the file that is causing problem. – Arthur Reutenauer May 26 '15 at 16:49
  • @Tasia maybe with enumerate package ... – juanuni May 26 '15 at 16:52

1 Answers1

12

You could use the ntheorem package to get the desired formatting of the hyp environment. (Be sure to compile the example code below twice, so that LaTeX can resolve the embedded cross-reference.)

enter image description here

\documentclass{article}
\usepackage{ntheorem}
\theoremseparator{:}
\newtheorem{hyp}{Hypothesis}

\begin{document}

\begin{hyp}[H\ref{hyp:first}] \label{hyp:first}
This is my first hypothesis.
\end{hyp}

\end{document}
Mico
  • 506,678
  • Doesn't seem to work anymore. ("Something's wrong, perhaps a missing \item") – reggie Apr 15 '22 at 08:10
  • @reggie - The code above does not cause an error when compiled with MacTeX2022, LaTeX2e <2021-11-15> patch level 1, and ntheorem Version 1.33 <2011/08/15>. Please tell me more about your document setup. For sure, the type of error message would appear to indicate that you're using a list-like environment, which isn't the case in the code I provided. – Mico Apr 15 '22 at 08:23