1

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}
  • What do you mean with “null hypothesis”? – egreg Aug 17 '17 at 17:37
  • I want it to be H_0 and H_1. – Ar1229 Aug 17 '17 at 17:43
  • Can you please add an approximate representation of the desired output? – egreg Aug 17 '17 at 17:46
  • I need something like that, to declare my hypothesis. I know I can do it by \textbf{$H_0$}: This is my hypothesis. But I need to keep track of them, and it also feels like cheating – Ar1229 Aug 17 '17 at 17:54
1

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

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.