# Varying style for chapter-references

I would like to refer to a chapter (roman numbering) partly with arabic numerals (e.g. as part of equation numbers) and partly with roman numerals (e.g. when refering directly to the chapter) ...

I've tried sth like:

\newcommand{\chapref}[1]{\def\thechapter{\roman{chapter}}\ref{#1}}


(this changed the counter format globally)

or

\newcommand{\chapref}[1]{\uppercase\expandafter{\romannumeral \ref{#1}}}


(in may case: compiled without warning but no effect..)

but this didn't work out ... any ideas?

-

## migrated from stackoverflow.comJun 30 '11 at 16:51

This question came from our site for professional and enthusiast programmers.

@firstshot: What is the problem with your solution? Please help use helping you. –  Paŭlo Ebermann Jun 30 '11 at 15:14
Don't redefine \thechapter if what you really want to do is change how \theequation looks: this will lead to other changes you don't want. Since it's \theequation you want to look differently, redefine that. –  Seamus Jun 30 '11 at 16:57

## 1 Answer

The command

\def\thechapter{\roman{chapter}}


switches the default chapter numbering to roman numerals. You should do this once, at the start. To use arabic numbers in the equation numbers, define these, too:

\def\theequation{\arabic{chapter}.\arabic{equation}}

-
@Paŭlo Ebermann and Seamus: Thanks a lot - actually I primarly wanted to use the arabic style and only occasionally the roman style - hence I was thinking the wrong way :) Your solution works perfectly fine! Ok, u probably know it - but maybe not everyone else out there ... so I used: 1. \def\thechapter{\Roman{chapter}} 2. \def\thesection{\arabic{chapter}.\arabic{section}} 3. \def\thesubsection{\arabic{chapter}.\arabic{section}.\arabic{subsection}} 4. \def\theequation{\arabic{chapter}.\arabic{equation}} 5. \def\thetheorem{\arabic{chapter}.\arabic{theorem}} Thanks for the help! cheers! –  firstshot Jul 1 '11 at 8:35
@firstshot: Welcome to TeX.sx! Please mark this answer as the solution by clicking the tick-mark on the left side. This marks the question as solved automatically. Please do not edit the title for this. Also posts in this section are for solutions only, so I converted your post, which is mostly a thank-you post, to a comment. You are very welcome to post your final solutions as own answers if required. However, in this simple case I would say the comment is sufficient. –  Martin Scharrer Jul 1 '11 at 9:19