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 was searching around my editor and found some templates that I never used before and I was just wondering exactly what do they mean and do. Someone can edit the title is you have a better suggestion.

%%Definitions for Figure-References
\newcommand{\fig}[1]{(figure \ref{#1})}
\newcommand{\FIG}[1]{figure \ref{#1}}

%%Definitions for Table-References
\newcommand{\tab}[1]{(table \ref{#1})}
\newcommand{\TAB}[1]{table \ref{#1}}

%%Definitions for Page-References
\newcommand{\page}[1]{(page \pageref{#1})}
\newcommand{\PAGE}[1]{page \pageref{#1}}

%%Definitions for Code
\newcommand{\precode}[1]{\textbf{\footnotesize #1}}
\newcommand{\code}[1]{\texttt{\footnotesize #1}}
share|improve this question
Have a look at this topic: Name of current section/figure –  Marco Daniel Aug 13 '11 at 10:41
I think this question is too localised... –  Seamus Aug 13 '11 at 13:24

2 Answers 2

up vote 3 down vote accepted

They are just macros to make cross-references and code snippet markups. Defining such macros is a good practice because you can modify the macros definition in one place and the changes will take effect throughout the document.

The following code shows you what they are for. You will get the idea!


%%Definitions for Figure-References

%%Definitions for Table-References

%%Definitions for Page-References

%%Definitions for Code
\newcommand\precode[1]{\textbf{\footnotesize #1}}
\newcommand\code[1]{\texttt{\footnotesize #1}}


\caption{This is a cat.}
For the detail see \fig{fig:cat} on \page{fig:cat}.

a & b \\\hline
c & d \\\hline
\caption{This is a table, not a desk!}
See \tab{tab:Schedule} on \page{tab:Schedule} for the detailed explanation.

You can type \code{var a = b - c;} in the source editor.


  1. You don't need to overload macro by capitalization if they do the same thing. Defining one of {\tab, \TAB, \TaB, etc} is enough.
  2. For printed document, we usually print both Figure/Table references together with page numbers. Therefore, you can combine Figure-Page and Table-Page as follows.

    \newcommand\tabpage[1]{Table~\ref{#1} on page~\pageref{#1}}


    \newcommand\figpage[1]{Figure~\ref{#1} on page~\pageref{#1}}
share|improve this answer
the do not the same! –  Herbert Aug 13 '11 at 10:43
@Herbert: Oh I see. I should check up my eyes. :-) –  xport Aug 13 '11 at 10:49
with fancyref it is \newcommand\tabpage[1]{Table~\vref{#1}} –  Herbert Aug 13 '11 at 13:15
+1 I see. Thanks. –  xport Aug 13 '11 at 14:19

they are not correct. Should be:

%%Definitions for Figure-References

%%Definitions for Table-References

%%Definitions for Page-References

%%Definitions for Code
\newcommand{\precode}[1]{\textbf{\footnotesize #1}}
\newcommand{\code}[1]{\texttt{\footnotesize #1}}

The ~ dosn't allow a line break between the word and the ref. They all save some keystrokes, you can say as seen in \fig{fig_label}. Same for table and page. The lowercase variants put this reference into (...) The last two are only abbreviations for typesetting precode in bold font and code in typewriter font, both in footnote size

share|improve this answer

Your Answer


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.