带有自定义标题的图形标签

带有自定义标题的图形标签

我目前正在为某期刊写一篇论文,但这篇论文的风格很独特,导致 LaTex 出现一些问题。让我说得更具体一些。以下是这篇论文的第一张图。

\begin{figure}[!tH]
\centering
\includegraphics[width=0.7\hsize]{fig1.eps}
\captionb{1}{This is a test caption.}
\label{test}
\end{figure}

我们可以看到,标题被修改了,它不是通常的标题,\caption{}而是\captionb{#}{}# 表示图形的编号(我承认这不是很聪明)。

现在,当我在文本图内写入时,\ref{test}我得到的图上数字 1 的位置出现了空白。我猜这是因为修改了 caption 命令。

MWE 可在此处找到:平均能量损失

main.tex

\documentclass[10pt,a4paper,twoside]{article}
\usepackage{epsfig}
\usepackage{baltlat6}
\usepackage{array}
\usepackage{here}
\usepackage{natbib}
\pagestyle{headings}

\usepackage[dvipdfm=true]{hyperref}
\hypersetup{pdftitle = The title of my PDF, pdfauthor = My name, pdfsubject= The subject, pdfkeywords = keyword1 keyword2 keyword3}
\hypersetup{colorlinks = true, linkcolor = blue, anchorcolor = red, citecolor = blue, filecolor = red, pagecolor = red, urlcolor = blue}

\begin{document}
\ \
\vspace{0.5mm}
\setcounter{page}{1}
\vspace{8mm}

\titlehead{Baltic Astronomy, vol.\,00, 0--000, 2014}

\titleb{TITLE}

\begin{authorl}
\authorb{Author}{}
\end{authorl}

\begin{addressl}
\addressb{}{Affiliation}
\end{addressl}

\submitb{Received: - ; accepted: -}

\begin{summary}
Abstarct
\end{summary}

\begin{keywords}
keywords
\end{keywords}

\resthead{title}
{author}

\sectionb{1}{INTRODUCTION}

\begin{figure}
\centering
\includegraphics[width=0.7\hsize]{example-image}
\captionb{1}{This is a test caption.}
\label{tst}
\end{figure}

As we can see in Fig. \ref{tst} there is ...

\end{document}

baltlat6.sty

% Baltic Astronomy Document Style BALTLAT6.STY  (updated 2007 Dec 05).

\font\norma=cmr10
\font\normbf=cmbx10
\font\smallbf=cmbx9
\font\smalit=cmti9
\font\itl=cmti9
\def\em{\it}
\def\norm{\normalsize}
%SOME LITHUANIAN LETTERS
\def\ac{a\kern-.35em\accent'30\kern-.05em}
\def\Ac{A\kern-.35em\accent'30\kern-.05em}
\def\uc{u\kern-.35em\accent'30\kern-.05em}
\def\Uc{U\kern-.35em\accent'30\kern-.05em}
\def\msf{\footnotesize}


%\@options
\lineskip 1pt
\normallineskip 1pt
\def\baselinestretch{1}
\parskip 1pt
\textwidth=125mm
\textheight=190mm
%\oddsidemargin=25.4mm
%\evensidemargin=9.78mm
\oddsidemargin=2.2mm % at twoside, but for the same position of text
\evensidemargin=2.2mm % at twoside, but for the same position of text
\baselineskip=11pt



\def\titlehead#1{\vskip-15mm{\noindent\it #1\norm}
\vskip15mm
\thispagestyle{empty}}

\def\fpagehead#1{
\thispagestyle{myheadings}
\markright{\it Baltic Astronomy, vol.#1.}
\markboth{\it Baltic Astronomy, vol.#1.}
{\it Baltic Astronomy, vol.#1.}
\norm}


\def\resthead#1#2{
\pagestyle{amyheadings}
\markright{\it #1}
\markboth{\it #2}{\it #1}
\norm}
\def\runninghead{\resthead}



\marginparwidth 2cm
\marginparsep 10pt
\topmargin 22.17pt

\headheight 12pt
\headsep 25pt

\advance\textheight by \topskip
\columnsep 10pt
\columnseprule 0pt
\footnotesep 8.4pt

\skip\footins 10.8pt plus 4pt minus 2pt
\floatsep 12pt plus 2pt minus 4pt
\textfloatsep 10pt plus 2pt minus 4pt
\intextsep 10pt plus 4pt minus 4pt


\def\captionb#1#2{\small\vspace{2mm}
\vbox{\baselineskip=9.5pt\hhuad{\bf Fig.\,#1.}
 \,#2} \baselineskip=11pt}

\def\captionr#1#2{\small\vspace{2mm}
\vbox{\baselineskip=9.5pt{\bf Fig.\,#1.}
 \,#2} \baselineskip=11pt}

\def\captionc#1#2{\small\begin{center}\vspace{2mm}
\vbox{\baselineskip=9.5pt{\bf Fig.\,#1.}
 \,#2}\end{center}\baselineskip=11pt}


\leftmargini 2.5em
\leftmarginii 2.2em
\leftmarginiii 1.87em
\leftmarginiv 1.7em
\leftmarginv 1em
\leftmarginvi 1em



\def\titleb#1{\noindent\hskip-.1pt{\parbox{123mm}{\bf #1}}\vspace{11mm}\norm}

\def\authorb#1#2{  #1$^{#2}$}
\def\addressb#1#2{\noindent{  $^{#1}$\,}
      \vtop{\hsize120mm\it\noindent\baselineskip10pt #2}\vskip.3mm\norm}


\def\authorl{\noindent\hskip.1pt}
\def\endauthorl{\vskip1mm\par\norm}

\def\addressl{\noindent\vskip.1pt}
\def\endaddressl{\vskip5mm\par\norm}

\def\submitb#1{\vskip2mm \noindent #1\vskip8mm}

\def\thanks#1{\vspace{4mm} ACKNOWLEDGMENTS.\ \ #1\par}

\def\sectionb#1#2{\vspace{5mm}\hbox{\kern-.9pt
{#1.\ \ }\vtop{\noindent #2}\nopagebreak}
\vspace{1mm} \noindent\baselineskip=11pt}

\def\subsectionb#1#2{\vspace{3mm}\hbox{\kern-.9pt
{\it #1.\ \ }\vtop{\noindent\it #2}\nopagebreak}
\vspace{.5mm} \noindent\baselineskip=11pt}

\def\subsubsectionb#1#2{\vspace{3mm}\hbox{\kern-.9pt
{#1.\ \ }\vtop{\noindent #2}\nopagebreak}
\vspace{.5mm} \noindent\baselineskip=11pt}


\def\summary{\vskip-5pt\noindent
\rightskip=0pc\leftskip=1pc%\parindent=\z@
 \baselineskip 10pt
{\bf Abstract.\ }}
\def\endsummary{\par\norm}


\def\keywords{\vskip 5pt\noindent
\rightskip=0pc\leftskip=1pc%\parindent=\z@
 \baselineskip 10pt
{\bf Key words:\ }}
\def\endkeywords{\par\norm}



% REFERENCES
%
\def\References{\vskip4mm
{\noindent
  REFERENCES\hfill}
  \vskip1mm

\norm}
\def\refb{\baselineskip=10pt
\vskip.3mm
\hangindent12pt\hangafter=1
\noindent\ignorespaces}
\def\endrefb{\endgroup}
%


\def\ps@myheadings{\let\@mkboth\@gobbletwo
\def\@oddhead{\hbox{}\it\rightmark \hfil\norm}
\def\@oddfoot{}\def\@evenhead{\it\leftmark\hbox {}\hfil\norm}
\def\@evenfoot{}\def\sectionmark##1{}\def\subsectionmark##1{}}

\def\ps@amyheadings{\let\@mkboth\@gobbletwo
\def\@oddhead{\hbox{}\it\rightmark \hfil\norma \thepage\norm}
\def\@oddfoot{}\def\@evenhead{\thepage\hfil\leftmark\hbox {}}
\def\@evenfoot{}\def\sectionmark##1{}\def\subsectionmark##1{}}

%TABLE TOOLS
\def\tablerule{\noalign{\vskip.7ex}\noalign{\hrule}\noalign{\vskip.5ex}}
\def\hhuad{\vrule height0pt depth0pt width10pt}%3.5mm
\def\huad{\vrule height0pt depth0pt width5pt}  %1.75mm
\def\sadd{\vrule height0pt depth0pt width.2em}
\def\badd{\vrule height0pt depth0pt width2em}
\def\add{\vrule height0pt depth0pt width.5em}
\def\addu{\vrule height0pt depth0pt width1.3em}
\def\addXcm{\vrule height0pt depth0pt width10truecm}
\def\qua{\vrule height0pt depth0pt width2pt}
\def\lhstrut{\vrule height10pt depth7pt width0pt}
\def\hstrut{\vrule height10pt depth0pt width0pt}
\def\lstrut{\vrule height0pt depth6pt width0pt}   %all of them
\def\llstrut{\vrule height1pt depth10pt width0pt} %not visible
\def\sstrut{\vrule height10pt depth5pt width0pt}
\def\hhstrut{\vrule height18pt depth0pt width0pt}
\def\lls{\vrule height0pt depth8pt width0pt}
\def\ddown{\lower2.5ex\hbox}
\def\ddow{\lower1.7ex\hbox}
\def\down{\lower1ex\hbox}
\def\uppp{\raise1ex\hbox}
\def\dnnn{\lower1ex\hbox}
\def\uuppp{\raise2ex\hbox}
\def\vm{\vskip3mm}
\def\hd{\hskip9.5mm}
\def\hs{\hskip2mm}
\def\hm{\hskip4mm}
\def\hll{\hd&\hfil\hd}
\def\hlm{\hm&\hfil\hm}
% ASTRONOMICAL ABBREVIATIONS
%
\def\sun{\hbox{$\odot$}}
\def\sq{\hbox{\rlap{$\sqcap$}$\sqcup$}}
\def\degr{\hbox{$^\circ$}}
\def\dgr{$^\circ\!$}
\def\arcmin{\hbox{$^\prime$}}
\def\arcsec{\hbox{$^{\prime\prime}$}}
\def\fd{\hbox{$.\!^{\rm d}$}}
\def\fh{\hbox{$.\!^{\rm h}$}}
\def\fm{\hbox{$.\!^{\rm m}$}}
\def\fs{\hbox{$.\!^{\rm s}$}}
\def\fdg{\hbox{$.\!^\circ$}}
\def\farcm{\hbox{$.\mkern-4mu^\prime$}}
\def\farcs{\hbox{$.\!\!^{\prime\prime}$}}
\def\fp{\hbox{$.\!\!^{\scriptscriptstyle\rm p}$}}

%\def~{\penalty100\thinspace}
\def\ts{\thinspace}
\def\oc{ $O\!-\!C$ }
\def\gmode{$g$-mode}
\def\pmode{$p$-mode}
\def\gmodes{$g$-modes}
\def\pmodes{$p$-modes}
\def\etal{et al.} %ApJlikes it this way now
\def\msun{$\,M_{\odot}$}
\def\rsun{$\,R_{\odot}$}
\def\lsun{$\,L_{\odot}$}
\def\te{$T_{\rm e}\,$}
\def\Te{$T_{\rm e}\,$}
\def\mstr{$\,M_{\star}$}
\def\rstr{$\,R_{\star}$}
\def\lstr{$\,L_{\star}$}
\def\angstr{\small A\kern-.57em\raise1.8ex\hbox{${\scriptscriptstyle\circ}$}$\,$}
\def\Pdot{$\dot P$}
\def\Tdot{$\dot T$}
\def\Rdot{$\dot R$}
\def\Tmax{$T_{\rm max}$}
\def\mitstar{$M\!$\raisebox{-.4ex}{$\star$}}
\def\mstar#1{$10^{-{#1}} {\rm M}_{\star}$}
\def\mh{${\rm M}_{\rm H}$}
\def\mhe{${\rm M_{\rm He}}$}
%the same definitions for using them in the math
\def\msunm{\,M_{\odot}}
\def\rsunm{\,R_{\odot}}
\def\lsunm{\,L_{\odot}}
\def\teff{T_{\rm eff}}
\def\Teff{T_{\rm eff}}
\def\mstrm{\,M_{\star}}
\def\rstrm{\,R_{\star}}
\def\lstrm{\,L_{\star}}
\def\Pdotm{\dot P}
\def\Tdotm{\dot T}
\def\Rdotm{\dot R}
\def\Tmaxm{T_{\rm max}}
\def\mstarm#1{10^{-{#1}} {\rm M}_{\star}}
\def\mhm{{\rm M}_{\rm H}}
\def\mhem{{\rm M_{\rm He}}}
%\chardef\o="1C
%\chardef\O="1F

%\ps@plain
\pagenumbering{arabic}
\onecolumn

那么,有办法解决这个问题吗?

答案1

\captionb在您的自定义中定义baltlat6.sty

\def\captionb#1#2{\small\vspace{2mm}
\vbox{\baselineskip=9.5pt\hhuad{\bf Fig.\,#1.}
 \,#2} \baselineskip=11pt}

所以它不是为\label-ref机制设计的。

在您的序言中添加以下几行,以便让那些自定义命令支持它:

\makeatletter
\def\captionb#1#2{\refstepcounter\@captype\small\vspace{2mm}
\vbox{\baselineskip=9.5pt\hhuad{\bfseries Fig.\,#1.}
 \,#2} \baselineskip=11pt}

\def\captionr#1#2{\refstepcounter\@captype\small\vspace{2mm}
\vbox{\baselineskip=9.5pt{\bfseries Fig.\,#1.}
 \,#2} \baselineskip=11pt}

\def\captionc#1#2{\refstepcounter\@captype\small\begin{center}\vspace{2mm}
\vbox{\baselineskip=9.5pt{\bfseries Fig.\,#1.}
 \,#2}\end{center}\baselineskip=11pt}
\makeatother

您修改后的 MWE:

\documentclass[10pt,a4paper,twoside]{article}
\usepackage{epsfig}
\usepackage{baltlat6}
\usepackage{array}
\usepackage{here}
\usepackage{natbib}
\pagestyle{headings}

\usepackage[dvipdfm=true]{hyperref}
\hypersetup{pdftitle = The title of my PDF, pdfauthor = My name, pdfsubject= The subject, pdfkeywords = keyword1 keyword2 keyword3}
\hypersetup{colorlinks = true, linkcolor = blue, anchorcolor = red, citecolor = blue, filecolor = red, pagecolor = red, urlcolor = blue}

\makeatletter
\def\captionb#1#2{\refstepcounter\@captype\small\vspace{2mm}
\vbox{\baselineskip=9.5pt\hhuad{\bfseries Fig.\,#1.}
 \,#2} \baselineskip=11pt}

\def\captionr#1#2{\refstepcounter\@captype\small\vspace{2mm}
\vbox{\baselineskip=9.5pt{\bfseries Fig.\,#1.}
 \,#2} \baselineskip=11pt}

\def\captionc#1#2{\refstepcounter\@captype\small\begin{center}\vspace{2mm}
\vbox{\baselineskip=9.5pt{\bfseries Fig.\,#1.}
 \,#2}\end{center}\baselineskip=11pt}
\makeatother

\begin{document}
\ \
\vspace{0.5mm}
\setcounter{page}{1}
\vspace{8mm}

\titlehead{Baltic Astronomy, vol.\,00, 0--000, 2014}

\titleb{TITLE}

\begin{authorl}
\authorb{Author}{}
\end{authorl}

\begin{addressl}
\addressb{}{Affiliation}
\end{addressl}

\submitb{Received: - ; accepted: -}

\begin{summary}
Abstarct
\end{summary}

\begin{keywords}
keywords
\end{keywords}

\resthead{title}
{author}

\sectionb{1}{INTRODUCTION}

\begin{figure}
\centering
\includegraphics[width=0.7\hsize]{fig1.eps}
\captionb{1}{This is a test caption.}
\label{tst}
\end{figure}

As we can see in Fig. \ref{tst} there is ...


\end{document}

现在产生:

enter image description here


编辑

由于\sectionb& friends 也缺少此功能,我建议您在序言中添加以下几行

\def\sectionb#1#2{\refstepcounter{section}\vspace{5mm}\hbox{\kern-.9pt
{#1.\ \ }\vtop{\noindent #2}\nopagebreak}
\vspace{1mm} \noindent\baselineskip=11pt}

\def\subsectionb#1#2{\refstepcounter{subsection}\vspace{3mm}\hbox{\kern-.9pt
{\it #1.\ \ }\vtop{\noindent\it #2}\nopagebreak}
\vspace{.5mm} \noindent\baselineskip=11pt}

\def\subsubsectionb#1#2{\refstepcounter{subsubsection}\vspace{3mm}\hbox{\kern-.9pt
{#1.\ \ }\vtop{\noindent #2}\nopagebreak}
\vspace{.5mm} \noindent\baselineskip=11pt}

编辑#2

由于baltlat6.sty没有为表格定义标题,我们可以定义三种类型,,,\captiontb对应于\captiontr,,用于图形,但用于表格内部。\captiontc\captionb\captionr\captionc

因此,请替换上面提到的所有附加代码,并在序言中放入以下几行:

\def\captionb#1#2{\refstepcounter{figure}\small\vspace{2mm}
\vbox{\baselineskip=9.5pt\hhuad{\bfseries Fig.\,#1.}
 \,#2} \baselineskip=11pt}

\def\captionr#1#2{\refstepcounter{figure}\small\vspace{2mm}
\vbox{\baselineskip=9.5pt{\bfseries Fig.\,#1.}
 \,#2} \baselineskip=11pt}

\def\captionc#1#2{\refstepcounter{figure}\small\begin{center}\vspace{2mm}
\vbox{\baselineskip=9.5pt{\bfseries Fig.\,#1.}
 \,#2}\end{center}\baselineskip=11pt}

\def\captiontb#1#2{\refstepcounter{table}\small\vspace{2mm}
\vbox{\baselineskip=9.5pt\hhuad{\bfseries Table\,#1.}
 \,#2} \baselineskip=11pt}

\def\captiontr#1#2{\refstepcounter{table}\small\vspace{2mm}
\vbox{\baselineskip=9.5pt{\bfseries Table\,#1.}
 \,#2} \baselineskip=11pt}

\def\captiontc#1#2{\refstepcounter{table}\small\begin{center}\vspace{2mm}
\vbox{\baselineskip=9.5pt{\bfseries Table\,#1.}
 \,#2}\end{center}\baselineskip=11pt}

\def\sectionb#1#2{\refstepcounter{section}\vspace{5mm}\hbox{\kern-.9pt
{#1.\ \ }\vtop{\noindent #2}\nopagebreak}
\vspace{1mm} \noindent\baselineskip=11pt}

\def\subsectionb#1#2{\refstepcounter{subsection}\vspace{3mm}\hbox{\kern-.9pt
{\it #1.\ \ }\vtop{\noindent\it #2}\nopagebreak}
\vspace{.5mm} \noindent\baselineskip=11pt}

\def\subsubsectionb#1#2{\refstepcounter{subsubsection}\vspace{3mm}\hbox{\kern-.9pt
{#1.\ \ }\vtop{\noindent #2}\nopagebreak}
\vspace{.5mm} \noindent\baselineskip=11pt}

相关内容