3

enter image description hereI'm trying to write a null hypothesis with my thesis, and I found this question Hypothesis in latex. But when I tried it, it did not work for me, as I had a typesetting error and the xcolor and fancyhdr page were the culprits. (I dont even understand how that is possible, but then again I'm super new at this, so maybe that's not surprising).

Anyway, I've read that I can use the amsthm package to write the hypothesis, but I haven't been able to find a working example.

\documentclass[12pt,a4paper,oneside]{book}
\usepackage{amsmath,amssymb,amsthm}
\newtheorem{hyp}{Hypothesis}
\begin{document}
\begin{hyp}
This is my first hypothesis.
\end{hyp}
\end{document}
Ar1229
  • 115
  • 1
  • 2
  • 10

1 Answers1

5

Is it what you want?

\documentclass[12pt,a4paper,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{thmtools}
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=0.6em,
headpunct=:
]{mystyle}
\declaretheorem[style=mystyle, name=Hypothesis, preheadhook={\renewcommand{\thehyp}{H\textsubscript{\arabic{hyp}}}}]{hyp}

\usepackage{cleveref}
\crefname{hyp}{hypothesis}{hypotheses}
\Crefname{hyp}{Hypothesis}{Hypotheses}

 \begin{document}
 \setcounter{hyp}{-1}
 \begin{hyp}[Test hypothesis] \label{hyp:a}This is my first hypothesis. \end{hyp}
 \begin{hyp} \label{hyp:b}This is my second hypothesis. \end{hyp}

  \Cref{hyp:a,hyp:b}.

 \end{document} 

enter image description here

Bernard
  • 271,350
  • This is amazing, but it does not work for me. It says Package thmtools warning: Your backend doesn't allow theorems on input line 18. Package thmtools error, \declaretheorem key 'spaceabove' not known – Ar1229 Aug 17 '17 at 22:04
  • It worked! I moved the amsmath package line up, and loading it before this. Thank you! It's exactly what I needed! – Ar1229 Aug 17 '17 at 22:10
  • @Ar1229 Please accept the answer. – George Aug 15 '19 at 06:36