(抱歉我的英语不好)我创建了一个会计来列举练习列表中的问题。最后我想引用给定的练习。但是 \label 和 \ref 命令对我不起作用。有人能帮帮我吗?
\documentclass[a4paper,12pt]{report}
\usepackage{amsmath,amsfonts,amscd,bezier}%gislaine
\usepackage{amssymb}
\usepackage[dvips]{graphicx}
\usepackage{pdfsync}
\usepackage{color}
\usepackage{hyperref}
\newcounter{eq}
\refstepcounter{eq}
%\setcounter{eq}{1}
\newcommand{\eq}{{\noindent {\bf{\arabic{eq}}}} \addtocounter{eq}{1}{\hspace{-0.1cm{{.}}}} }
\newcommand{\eqz}{{\setcounter{eq}{1}} {{\arabic{eq}}} \addtocounter{eq}{1}\hspace{-0.1cm{{.}}}}
%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pagestyle{myheadings} \thispagestyle{empty}
\eq \label{eq1} Let $X$ be such that....
\eq \label{eq2}In this exercise consider $Y=2$ ...
\eq \label{eq3} Consider, in exercise \ref{eq1} (I would like to see the issue number 1)
\eq Here, consider in exercise \ref{eq2} (I would like to see the issue number 2) $Y=3$...
\eq Here, consider in exercise \ref{eq3} (I would like to see the issue number 3) $Y=5$...
\end{document}
答案1
您所需要的只是创建计数器、设置它、设置一个引用名称,然后就可以开始引用它。
让我用一个简短的例子来解释一下。
\documentclass{article}
\usepackage{environ, hyperref, cleveref}
\newcounter{QuotCount}
\setcounter{QuotCount}{0}
%
\NewEnviron{fquote}[3][0.8]{%
\refstepcounter{QuotCount}%
\par\vspace{0.5cm}\noindent
\begin{tikzpicture} %\pbox[pos][height][inner-pos]{max-width}{text}
\node[font=\large\bfseries](box){%
\pbox{#1\linewidth}{\BODY \label{quot:#3}}};
\node[inner sep=1pt,very thin,anchor=east,pink,font=\bfseries\fontsize{48}{48}\selectfont,yshift=-5pt]at(box.north west){``};
\node[inner sep=1pt,very thin,pink,anchor=west,font=\bfseries\fontsize{48}{48}\selectfont,yshift=-8pt,xshift=-2pt]at(box.south east){''};
\node[inner sep=1pt,very thin,anchor=north west,gray,font=\small\sffamily]at(box.south west){\begin{minipage}[t][1cm][t]{0.8\linewidth}
\ {#2}\end{minipage}};
\end{tikzpicture}\par
}
\crefname{QuotCount}{quote}{quotes}
\Crefname{Quotcount}{Quote}{Quotes}
\begin{document}
\begin{hsquote}{Antoine de Saint-Exupéry}{adesigner}
A designer knows that has has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.
\end{hsquote}
\Cref{quot:designer} is a quote on design used in the tufte-book.
\end{document}
答案2
已经有包了,所以你可能需要使用它:
\documentclass[a4paper,12pt]{report}
\usepackage{amsmath,amsfonts,amscd,bezier}
\usepackage{amssymb}
\usepackage{color}
%%%%%%%%%%%%%%%%%%%%
\usepackage[thref]{ntheorem}
\usepackage{cleveref}
\newtheorem{exercise}{Exercise}
\newtheorem{nonum}{}
\begin{document}
\begin{exercise}\label{ex:foo}
foo
\end{exercise}
\begin{exercise}\label{ex:bar}
bar
\end{exercise}
\begin{nonum}\label{noex:foo}
foo
\end{nonum}
\begin{nonum}\label{noex:bar}
bar
\end{nonum}
References: \cref{ex:foo}, \cref{ex:bar} and \Cref{ex:foo}.
References: \cref{noex:foo}, \cref{noex:bar} and \Cref{noex:foo}.
\end{document}
以下是一些手册: http://www.ctan.org/pkg/cleveref, http://www.ctan.org/pkg/ntheorem。这里有一个替代方案: http://www.ctan.org/pkg/theorem。