I used the answer here to help me create a document where numbering for theorems and the like appears on the left. But I would like to be able to reference and hyperlink back to these theorems/definitions/etc in my document. When I added hyperref
and clicked on the links, they both sent me back to the front page. (I created a newpage
in the code below to make the issue clearer, and I changed the documentclass
from article
to book
since that is what I am using. The issue persists in either case.)
Any ideas to get the hyperlinks working correctly?
\documentclass{book}
\usepackage{showframe} % just for the example
\usepackage{amsthm}
\usepackage{enumitem}
\usepackage{xparse}
\usepackage{hyperref}
\usepackage{lipsum}
\newtheoremstyle{fctaylor}% name
{\topsep}% Space above
{\topsep}% Space below
{\normalfont}% Body font
{}% Indent amount (empty = no indent, \parindent = para indent)
{\bfseries}% Thm head font
{}% Punctuation after thm head
{0pt}% Space after thm head: " " = normal interword space;
{\makethmhead{#1}{#2}{#3}}
\newlength\fctaylortheoremindent
\AtBeginDocument{\setlength\fctaylortheoremindent{3em}} % <- customize here
\newlength\fctaylorlabelsep
\AtBeginDocument{\setlength\fctaylorlabelsep{1em}} % <- customize here
\makeatletter
\newcommand{\makethmhead}[3]{%
\gdef\thisthmhead{%
\makebox[\fctaylortheoremindent][l]{\bfseries#2}%
{\bfseries#1}%
\@ifnotempty{#3}{ (#3)}%
\hspace{\fctaylorlabelsep}%
}%
}
\makeatother
\newenvironment{fctayloritemize}
{\list{}{%
\leftmargin=\fctaylortheoremindent
\labelwidth=\dimexpr\fctaylortheoremindent-\labelsep\relax
\itemindent=0pt
}}
{\endlist}
\NewDocumentCommand{\newfctaylortheorem}{smomo}{%
\IfBooleanTF{#1}
{\newtheorem*{fctaylor@#2}{#4}}
{\IfNoValueTF{#3}
{\IfNoValueTF{#5}
{\newtheorem{fctaylor@#2}{#4}}
{\newtheorem{fctaylor@#2}{#4}[#5]}}
{\newtheorem{fctaylor@#2}[fctaylor@#3]{#4}}}%
\NewDocumentEnvironment{#2}{o}
{\IfNoValueTF{##1}{\begin{fctaylor@#2}}{\begin{fctaylor@#2}[##1]}%
\begin{fctayloritemize}\item[\thisthmhead\hfill]}
{\end{fctayloritemize}\end{fctaylor@#2}}%
}
\theoremstyle{fctaylor}
\newfctaylortheorem{thm}{Theorem}[section]
\newfctaylortheorem*{defn}{Definition}
\begin{document}
\section{One}
\begin{defn}
\lipsum*[2]
\end{defn}
\newpage
\begin{thm}\label{A}
\lipsum*[2]
\end{thm}
\begin{thm}[Somebody]\label{B}
Something that should show how the text is split across line boundaries
and is correctly indented. And some equivalent conditions:
\begin{enumerate}[label=\upshape(\alph*),ref=(\alph*)]
\item a condition
\item another
\item and another
\end{enumerate}
which show the point made.
\end{thm}
\newpage
Here are the references: \ref{A} and \ref{B}.
\end{document}
hyperref
with the answer I gave to your other similar question, you'll see it works out of the box. – egreg Jul 23 '18 at 20:33