GeneralTo get a sequence of equations number as 4, 5, 6, 6-a, 6-b, 7.

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
louispic
Posts: 2
Joined: Sun May 29, 2022 5:37 am

To get a sequence of equations number as 4, 5, 6, 6-a, 6-b, 7.

Post by louispic »

Someone could provide me a solution? I refer to the book: A Guide To LATEX by Helmut Kopka & Patrick W. Daly, Chapter 7, page 199, Example 4. I have copied exactly the code that appears in the book, but when I call \alpheqn , it does not work. Here is the code I use:

Code: Select all

\documentclass{article}
\newcounter{saveeqn}
\newcommand{\alpheqn}{\setcounter{saveeqn}{\value{equation}}%
	\setcounter{saveeqn}\setcounter{equation}{0}%
	\renewcommand{\theequation}
	{\mbox{\arabic{saveeqn}-\alph{equation}}}}
\newcommand{\reseteqn}{\setcounter{equation}{\value{saveeqn}}%
	\renewcommand{\theequation}{\arabic{equation}}}
\begin{document}
\begin{equation}
	\frac{1}{2}
\end{equation}

\alpheqn ----------> That one does NOT work????? Any solution????

\begin{equation}
	\frac{x}{y}
\end{equation}

\begin{equation}
	\frac{10}{12}
\end{equation}

\reseteqn -------> That one works well

\begin{equation}
	\frac{100}{200}
\end{equation}

\end{document}
Thanks for your help and reply
LOUIS
_________________

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

To get a sequence of equations number as 4, 5, 6, 6-a, 6-b, 7.

Post by rais »

Within the \alpheqn command, you're trying to set the saveeqn counter twice and that second call is incomplete.

Code: Select all

\documentclass{article}
\newcounter{saveeqn}
\newcommand{\alpheqn}{\setcounter{saveeqn}{\value{equation}}%
%  \setcounter{saveeqn}<-- this one
  \setcounter{equation}{0}%
  \renewcommand{\theequation}
  {\mbox{\arabic{saveeqn}-\alph{equation}}}%
}
\newcommand{\reseteqn}{\setcounter{equation}{\value{saveeqn}}%
\renewcommand{\theequation}{\arabic{equation}}}
\begin{document}
\begin{equation}
\frac{1}{2}
\end{equation}

\alpheqn ----------> That one does NOT work????? Any solution????

\begin{equation}
\frac{x}{y}
\end{equation}

\begin{equation}
\frac{10}{12}
\end{equation}

\reseteqn -------> That one works well

\begin{equation}
\frac{100}{200}
\end{equation}

\end{document}
works for me.

KR
Rainer
louispic
Posts: 2
Joined: Sun May 29, 2022 5:37 am

To get a sequence of equations number as 4, 5, 6, 6-a, 6-b, 7.

Post by louispic »

Rais. Thanks very much. It works. The mistake comes from the book. Thanks again. I have made another post and if you can look at it, I would be pleased to get a reply from you. Here is the post: The same book, chapter 6, page 170, exercise 6.8 which can be read as follows:
----------
Copy the lines at the right to a file name demo.eps and then include it in a LaTeX document, with some normal text above and below it. The result should appear as: (in the book we can see a figure composed by a circle surrounded by triangles.
----------
The lines at the right are as follows:
----------
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 169 158 233 242
220 200 moveto
200 200 20 0 360 arc
170 170 moveto
230 220 lineto
170 210 lineto
225 160 lineto
205 240 lineto
170 170 lineto
stroke
showpage
----------
My understanding is the lines should be written into a software such as illustrator? The created file must be saved as demo.eps. Then, I call the .eps file withing the LaTeX file.
_______
Can you tell me the right process to follow? And, how can I create the .eps file?
_______
Thanks for your reply
________________________
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

To get a sequence of equations number as 4, 5, 6, 6-a, 6-b, 7.

Post by rais »

Sorry for the late reply, I was on the road.
AFAICS, you don't need any special software, you just dump those lines into `demo.eps'.
From within LaTeX, you could use its {filecontents} environment for that:

Code: Select all

\documentclass{article}
\begin{filecontents*}{demo.eps}
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 169 158 233 242
220 200 moveto
200 200 20 0 360 arc
170 170 moveto
230 220 lineto
170 210 lineto
225 160 lineto
205 240 lineto
170 170 lineto
stroke
showpage
\end{filecontents*}
\usepackage{graphicx}
\begin{document}
\includegraphics{demo}
\end{document}
KR
Rainer
Post Reply