Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I made a 'hypothesis' custom counter in order to let LaTeX handle my hypothesis reference. My code is

\newcounter{hypothese}

\refstepcounter{hypothese}\label{hypo:lenght_of_words}
\refstepcounter{hypothese}\label{hypo:blue_word}

I think thant the words will be longer in this condition (hypothesis 
\ref{hypo:lenght_of_words}) and that the word \emph{blue} will be user more 
frenquently than in the next situation (hypothesis \ref{hypo:blue_word}). 

% ... statistical computing

As predicted in hypothesis \ref{hypo:blue_word}, the word \enquote{blue} is much more 
used than in the natural condition.

The output is what I wanted :

I think thant the words will be longer in this condition (hypothesis 1) and that the 
word blue will be user more frenquently than in the next situation (hypothesis 2).

As predicted in hypothesis 2, the word « blue » is much more used than in the natural
condition.

Now I want the hypothesis to use the \Alph{} style for numbering (A,B,C,...) but I don't know how to set the \ref{} command to return a letter. Can someone help me?

share|improve this question
    
Welcome to TeX.sx! –  egreg Apr 20 '13 at 13:05
3  
Write \renewcommand{\thehypothese}{\Alph{hypothese}} after defining your hypothese counter. –  Jubobs Apr 20 '13 at 13:08
    
What is wrong with having amsthm handle all the chores? –  vonbrand Apr 20 '13 at 13:18
    
@Jubobs Please make that an answer –  Joseph Wright Aug 13 '13 at 12:59

1 Answer 1

up vote 5 down vote accepted

By default, \newcounter{hypothese} will set the numbering style of the newly created hypothese counter to arabic (1, 2, 3,...). However, the numbering style can easily be changed. For instance, to set the style to capital letters (A, B, C,...), you should insert

\renewcommand{\thehypothese}{\Alph{hypothese}}

preferably right after defining the counter in question (see my code below). Two compilations might be required to obtain the desired result.

enter image description here


Side note: You can save yourself some hassle by avoiding hardcoding "hypothesis". With your current approach, if you decide, at a later stage, to change all cross-reference instances of "Hypothesis" in your document to "Assumption", you're in for some tedious and error-prone search & replace. A more maintainable alternative is to use the prettyref package and its \newrefformat and \prettyref commands; for instance, if you decide to substitute "Assumption" for "Hypothesis" throughout your document at a later stage, you can simply substitute Assumption for Hypothesis in the second argument of the \newrefformat command. The change will be reflected throughout the document. An even more powerful, albeit not as straightforward to use, package for that is cleveref.


\documentclass{article}

\usepackage{csquotes}
\setlength\parindent{0pt}
\usepackage{prettyref}
\newrefformat{hypo}{Hypothesis~\ref{#1}}

\begin{document}

\newcounter{hypothese}
\renewcommand{\thehypothese}{\Alph{hypothese}}

\refstepcounter{hypothese}\label{hypo:lenght_of_words}
Hypothesis~\thehypothese\\[1em]
\refstepcounter{hypothese}\label{hypo:blue_word}
Hypothesis~\thehypothese\\

I think thant the words will be longer in this condition
(\prettyref{hypo:lenght_of_words}) and that the word \emph{blue}
will be user more frequently than in the next situation (\prettyref{hypo:blue_word}).\\

% ... statistical computing

As predicted in \prettyref{hypo:blue_word}, the word \enquote{blue} is much more 
used than in the natural condition.

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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