hyperref.styで節をゴシック体にするとエラーとなる

hyperref.styで節をゴシック体にするとエラーとなる

- 栃折 成紀 の投稿
返信数: 2
hyperref.styで節をゴシック体にしたいのですが、次のエラーとなりました。タイプセットすることはできますか?

%test.tex---------------------------------------------------------------------------------------
\documentclass[a4j]{jarticle}
\usepackage[dvipdfmx]{hyperref}
\usepackage{amsmath}

\begin{document}

\section{\gtfamily a}

\end{document}
%test.log---------------------------------------------------------------------------------------
This is e-pTeX, Version 3.14159265-p3.8.3-191112-2.6 (sjis) (TeX Live 2020/W32TeX) (preloaded format=platex 2020.5.16) 5 JUN 2020 00:53
entering extended mode
\write18 enabled.
%&-line parsing enabled.
**test
(./test.tex
pLaTeX2e <2020-04-12> (based on LaTeX2e <2020-02-02> patch level 5)
L3 programming layer <2020-05-15>
(c:/usr/local/share/texmf-dist/tex/platex/base/jarticle.cls
Document Class: jarticle 2020/01/03 v1.8e Standard pLaTeX class
\c@@paper=\count166
(c:/usr/local/share/texmf-dist/tex/platex/base/jsize10.clo
File: jsize10.clo 2020/01/03 v1.8e Standard pLaTeX file (size option)
)
\c@part=\count167
\c@section=\count168
\c@subsection=\count169
\c@subsubsection=\count170
\c@paragraph=\count171
\c@subparagraph=\count172
\c@figure=\count173
\c@table=\count174
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\symmincho=\mathgroup4
LaTeX Font Info: Overwriting symbol font `mincho' in version `bold'
(Font) JY1/mc/m/n --> JY1/gt/m/n on input line 615.
\toclineskip=\dimen150
\@lnumwidth=\dimen151
\bibindent=\dimen152
\heisei=\count175
)
(c:/usr/local/share/texmf-dist/tex/latex/hyperref/hyperref.sty
Package: hyperref 2020-05-15 v7.00e Hypertext links for LaTeX

(c:/usr/local/share/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty
Package: ltxcmds 2019/12/15 v1.24 LaTeX kernel commands for general use (HO)
)
(c:/usr/local/share/texmf-dist/tex/generic/iftex/iftex.sty
Package: iftex 2020/03/06 v1.0d TeX engine tests
)
(c:/usr/local/share/texmf-dist/tex/latex/pdftexcmds/pdftexcmds.sty
Package: pdftexcmds 2019/11/24 v0.31 Utility functions of pdfTeX for LuaTeX (HO
)

(c:/usr/local/share/texmf-dist/tex/generic/infwarerr/infwarerr.sty
Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO)
)
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode not found.
)
(c:/usr/local/share/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks16
)
(c:/usr/local/share/texmf-dist/tex/generic/kvsetkeys/kvsetkeys.sty
Package: kvsetkeys 2019/12/15 v1.18 Key value parser (HO)
)
(c:/usr/local/share/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty
Package: kvdefinekeys 2019-12-19 v1.6 Define keys (HO)
)
(c:/usr/local/share/texmf-dist/tex/generic/pdfescape/pdfescape.sty
Package: pdfescape 2019/12/09 v1.15 Implements pdfTeX's escape features (HO)
)
(c:/usr/local/share/texmf-dist/tex/latex/hycolor/hycolor.sty
Package: hycolor 2020-01-27 v1.10 Color options for hyperref/bookmark (HO)
)
(c:/usr/local/share/texmf-dist/tex/latex/letltxmacro/letltxmacro.sty
Package: letltxmacro 2019/12/03 v1.6 Let assignment for LaTeX macros (HO)
)
(c:/usr/local/share/texmf-dist/tex/latex/auxhook/auxhook.sty
Package: auxhook 2019-12-17 v1.6 Hooks for auxiliary files (HO)
)
(c:/usr/local/share/texmf-dist/tex/latex/kvoptions/kvoptions.sty
Package: kvoptions 2019/11/29 v3.13 Key value format for package options (HO)
)
\@linkdim=\dimen153
\Hy@linkcounter=\count176
\Hy@pagecounter=\count177

(c:/usr/local/share/texmf-dist/tex/latex/hyperref/pd1enc.def
File: pd1enc.def 2020-05-15 v7.00e Hyperref: PDFDocEncoding definition (HO)
Now handling font encoding PD1 ...
... no UTF-8 mapping file for font encoding PD1
)
(c:/usr/local/share/texmf-dist/tex/generic/intcalc/intcalc.sty
Package: intcalc 2019/12/15 v1.3 Expandable calculations with integers (HO)
)
(c:/usr/local/share/texmf-dist/tex/generic/etexcmds/etexcmds.sty
Package: etexcmds 2019/12/15 v1.7 Avoid name clashes with e-TeX commands (HO)
)
\Hy@SavedSpaceFactor=\count178
Package hyperref Info: Hyper figures OFF on input line 4464.
Package hyperref Info: Link nesting OFF on input line 4469.
Package hyperref Info: Hyper index ON on input line 4472.
Package hyperref Info: Plain pages OFF on input line 4479.
Package hyperref Info: Backreferencing OFF on input line 4484.
Package hyperref Info: Implicit mode ON; LaTeX internals redefined.
Package hyperref Info: Bookmarks ON on input line 4717.
\c@Hy@tempcnt=\count179

(c:/usr/local/share/texmf-dist/tex/latex/url/url.sty
\Urlmuskip=\muskip16
Package: url 2013/09/16 ver 3.4 Verb mode for urls, etc.
)
LaTeX Info: Redefining \url on input line 5076.
\XeTeXLinkMargin=\dimen154

(c:/usr/local/share/texmf-dist/tex/generic/bitset/bitset.sty
Package: bitset 2019/12/09 v1.3 Handle bit-vector datatype (HO)

(c:/usr/local/share/texmf-dist/tex/generic/bigintcalc/bigintcalc.sty
Package: bigintcalc 2019/12/15 v1.5 Expandable calculations on big integers (HO
)
))
\Fld@menulength=\count180
\Field@Width=\dimen155
\Fld@charsize=\dimen156
Package hyperref Info: Hyper figures OFF on input line 6347.
Package hyperref Info: Link nesting OFF on input line 6352.
Package hyperref Info: Hyper index ON on input line 6355.
Package hyperref Info: backreferencing OFF on input line 6362.
Package hyperref Info: Link coloring OFF on input line 6367.
Package hyperref Info: Link coloring with OCG OFF on input line 6372.
Package hyperref Info: PDF/A mode OFF on input line 6377.
LaTeX Info: Redefining \ref on input line 6417.
LaTeX Info: Redefining \pageref on input line 6421.

(c:/usr/local/share/texmf-dist/tex/generic/atbegshi/atbegshi.sty
Package: atbegshi 2019/12/05 v1.19 At begin shipout hook (HO)
)
\Hy@abspage=\count181
\c@Item=\count182
\c@Hfootnote=\count183
)
Package hyperref Info: Driver: hdvipdfm.

(c:/usr/local/share/texmf-dist/tex/latex/hyperref/hdvipdfm.def
File: hdvipdfm.def 2020-05-15 v7.00e Hyperref driver for dvipdfm
\pdfm@box=\box61
\c@Hy@AnnotLevel=\count184
\HyField@AnnotCount=\count185
\Fld@listcount=\count186
\c@bookmark@seq@number=\count187

(c:/usr/local/share/texmf-dist/tex/latex/rerunfilecheck/rerunfilecheck.sty
Package: rerunfilecheck 2019/12/05 v1.9 Rerun checks for auxiliary files (HO)

(c:/usr/local/share/texmf-dist/tex/latex/atveryend/atveryend.sty
Package: atveryend 2019-12-11 v1.11 Hooks at the very end of document (HO)
Package atveryend Info: \enddocument detected (standard20110627).
)
(c:/usr/local/share/texmf-dist/tex/generic/uniquecounter/uniquecounter.sty
Package: uniquecounter 2019/12/15 v1.4 Provide unlimited unique counter (HO)
)
Package uniquecounter Info: New unique counter `rerunfilecheck' on input line 2
86.
)
\Hy@SectionHShift=\skip49
)
(c:/usr/local/share/texmf-dist/tex/latex/amsmath/amsmath.sty
Package: amsmath 2020/01/20 v2.17e AMS math features
\@mathmargin=\skip50

For additional information on amsmath, use the `?' option.
(c:/usr/local/share/texmf-dist/tex/latex/amsmath/amstext.sty
Package: amstext 2000/06/29 v2.01 AMS text

(c:/usr/local/share/texmf-dist/tex/latex/amsmath/amsgen.sty
File: amsgen.sty 1999/11/30 v2.0 generic functions
\@emptytoks=\toks17
\ex@=\dimen157
))
(c:/usr/local/share/texmf-dist/tex/latex/amsmath/amsbsy.sty
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
\pmbraise@=\dimen158
)
(c:/usr/local/share/texmf-dist/tex/latex/amsmath/amsopn.sty
Package: amsopn 2016/03/08 v2.02 operator names
)
\inf@bad=\count188
LaTeX Info: Redefining \frac on input line 227.
\uproot@=\count189
\leftroot@=\count190
LaTeX Info: Redefining \overline on input line 389.
\classnum@=\count191
\DOTSCASE@=\count192
LaTeX Info: Redefining \ldots on input line 486.
LaTeX Info: Redefining \dots on input line 489.
LaTeX Info: Redefining \cdots on input line 610.
\Mathstrutbox@=\box62
\strutbox@=\box63
\big@size=\dimen159
LaTeX Font Info: Redeclaring font encoding OML on input line 733.
LaTeX Font Info: Redeclaring font encoding OMS on input line 734.
\macc@depth=\count193
\c@MaxMatrixCols=\count194
\dotsspace@=\muskip17
\c@parentequation=\count195
\dspbrk@lvl=\count196
\tag@help=\toks18
\row@=\count197
\column@=\count198
\maxfields@=\count199
\andhelp@=\toks19
\eqnshift@=\dimen160
\alignsep@=\dimen161
\tagshift@=\dimen162
\tagwidth@=\dimen163
\totwidth@=\dimen164
\lineht@=\dimen165
\@envbody=\toks20
\multlinegap=\skip51
\multlinetaggap=\skip52
\mathdisplay@stack=\toks21
LaTeX Info: Redefining \[ on input line 2859.
LaTeX Info: Redefining \]
on input line 2860.
)
(c:/usr/local/share/texmf-dist/tex/latex/l3backend/l3backend-dvips.def
File: l3backend-dvips.def 2020-05-05 L3 backend support: dvips
\l__pdf_internal_box=\box64
\g__pdf_backend_object_int=\count266
\l__pdf_backend_content_box=\box65
\l__pdf_backend_model_box=\box66
\g__pdf_backend_annotation_int=\count267
\g__pdf_backend_link_int=\count268
\g__pdf_backend_link_sf_int=\count269
)
(./test.aux)
\openout1 = `test.aux'.

LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for JY1/mc/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for JT1/mc/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for PD1/pdf/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
\AtBeginShipoutBox=\box67
Package hyperref Info: Link coloring OFF on input line 5.
(c:/usr/local/share/texmf-dist/tex/latex/hyperref/nameref.sty
Package: nameref 2019/09/16 v2.46 Cross-referencing by name of section

(c:/usr/local/share/texmf-dist/tex/latex/refcount/refcount.sty
Package: refcount 2019/12/15 v3.6 Data extraction from label references (HO)
)
(c:/usr/local/share/texmf-dist/tex/generic/gettitlestring/gettitlestring.sty
Package: gettitlestring 2019/12/15 v1.6 Cleanup title references (HO)
)
\c@section@level=\count270
)
LaTeX Info: Redefining \ref on input line 5.
LaTeX Info: Redefining \pageref on input line 5.
LaTeX Info: Redefining \nameref on input line 5.

(./test.out) (./test.out)
\@outlinefile=\write3
\openout3 = `test.out'.



Package hyperref Warning: Rerun to get /PageLabels entry.

LaTeX Font Info: Font shape `JT1/mc/b/n' in size <14.4> not available
(Font) Font shape `JT1/mc/bx/n' tried instead on input line 7.
LaTeX Font Info: Font shape `JT1/mc/bx/n' in size <14.4> not available
(Font) Font shape `JT1/gt/m/n' tried instead on input line 7.
LaTeX Font Info: Font shape `JY1/mc/b/n' in size <14.4> not available
(Font) Font shape `JY1/mc/bx/n' tried instead on input line 7.
LaTeX Font Info: Font shape `JY1/mc/bx/n' in size <14.4> not available
(Font) Font shape `JY1/gt/m/n' tried instead on input line 7.
LaTeX Font Info: Font shape `JT1/gt/b/n' in size <14.4> not available
(Font) Font shape `JT1/gt/bx/n' tried instead on input line 7.
LaTeX Font Info: Font shape `JT1/gt/bx/n' in size <14.4> not available
(Font) Font shape `JT1/gt/m/n' tried instead on input line 7.
LaTeX Font Info: Font shape `JY1/gt/b/n' in size <14.4> not available
(Font) Font shape `JY1/gt/bx/n' tried instead on input line 7.
LaTeX Font Info: Font shape `JY1/gt/bx/n' in size <14.4> not available
(Font) Font shape `JY1/gt/m/n' tried instead on input line 7.
! Missing \endcsname inserted.
<to be read again>
\@elt
l.7 \section{\gtfamily a}

?
栃折 成紀 への返信

Re: hyperref.styで節をゴシック体にするとエラーとなる

- Yamamoto Munehiro "munepi" の投稿
%#!ptex2pdf -l
\documentclass[a4j]{jarticle}
\usepackage[dvipdfmx]{hyperref}
\usepackage{amsmath}

\begin{document}

%\section{\gtfamily a}
\section[a]{\gtfamily a}

\end{document}

ここでは、なぜこうすべきかの理由を割愛しますが、
hyperrefパッケージを使うということは、
PDF栞、目次、節見出しすべてに影響が出ます。
それゆえ、hyperrefパッケージを使う場合は、基本的に「\section{節見出し}」のみとすべきと思います。
どうしても \section 内部で書体変更をせずに、上記のようになさりたいというのであれば、少なくとも
\section[節見出し]{\gtfamily 節見出し}
とすべきです。
Yamamoto Munehiro "munepi" への返信

Re: hyperref.styで節をゴシック体にするとエラーとなる

- 栃折 成紀 の投稿
ご教授ありがとうございます。お示しいただきました
\section[a]{\gtfamily a}
で確かにゴシック体でタイプセットできましたが、\subsection だと、目次でゴシック体でなくなります。

自己解決ですが、\texorpdfstring を使うとこの問題も解決するようです。返信いただきありがとうございました。

%test.tex---------------------------------------------------------------------------------------
\documentclass[a4j]{jarticle}
\usepackage[dvipdfmx,bookmarks=true,bookmarksnumbered=true,colorlinks=true,linkcolor=blue,pdfborder={0 0 0}]{hyperref}
\usepackage{pxjahyper}
\usepackage{amsmath}

\begin{document}

\tableofcontents

\section[節名をゴシック体]{\gtfamily 節名をゴシック体}

\subsection[小節名が目次ではゴシック体でなくなる]{\gtfamily 小節名が目次ではゴシック体でなくなる}

\subsection{\texorpdfstring{\gtfamily 小節名を目次でもゴシック体に}{小節名を目次でもゴシック体に}}

\end{document}