Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: makeindex index cannot locate at chapter name's tail #4762

Closed
bubifengyun opened this issue Jul 10, 2018 · 5 comments
Closed

Bug: makeindex index cannot locate at chapter name's tail #4762

bubifengyun opened this issue Jul 10, 2018 · 5 comments

Comments

@bubifengyun
Copy link

Thank you,

pandoc version

pandoc 2.2.1
Compiled with pandoc-types 1.17.4.2, texmath 0.11, skylighting 0.7.0.2

exact command

$ pandoc test.md --to latex --from markdown --output result.tex --template template.tex --pdf-engine xelatex

exact input

here two files, one test.md, one template.tex

This is test.md,

# Test pandoc\index{pandoc} chapter {#chap:pandocchapter} 
# Test pandoc\index{pandoc} {#chap:pandoc} 

here is template.tex

\documentclass{ctexbook}
\RequirePackage{etoolbox}
\RequirePackage[centering,a4paper,body={16cm,22cm}]{geometry} %设置版面
\RequirePackage{fancyhdr}
\RequirePackage{pageslts}
\RequirePackage[titles]{tocloft}
\RequirePackage{mathtools,amsthm,amsfonts,amssymb,bm}
\RequirePackage[defaultsups]{newtxtext}
\RequirePackage{newtxmath}
\RequirePackage[opentype]{sourcecodepro}
\RequirePackage{upgreek}
\RequirePackage{wasysym}
\RequirePackage{anyfontsize}
\RequirePackage{metalogo,doc}
\RequirePackage{array}
\RequirePackage{threeparttable}
\RequirePackage{dcolumn}
\RequirePackage{multirow}
\RequirePackage{booktabs}
\RequirePackage{graphicx}
\RequirePackage{caption}
\RequirePackage[list=off]{bicaption}
\RequirePackage{subcaption}
\RequirePackage[backend=biber,style=gb7714-2015]{biblatex}
\RequirePackage{xcolor}
\RequirePackage{textcomp}
\RequirePackage[xetex, bookmarksnumbered, colorlinks, urlcolor=black, linkcolor=black, citecolor=black, plainpages=false, pdfstartview=FitH]{hyperref}
\RequirePackage{longtable}
\RequirePackage[perpage, bottom]{footmisc}
\RequirePackage[inline]{enumitem}
\RequirePackage{pdfpages}
\RequirePackage{calc}
\RequirePackage{algorithm, algorithmicx, algpseudocode}
\RequirePackage{siunitx}
\RequirePackage{tikz}
\RequirePackage{imakeidx}
\makeindex
\begin{document}
$body$
\printindex
\end{document}

the output received, it is result.tex

\documentclass{ctexbook}

\RequirePackage{etoolbox}
\RequirePackage[centering,a4paper,body={16cm,22cm}]{geometry} %设置版面
\RequirePackage{fancyhdr}
\RequirePackage{pageslts}
\RequirePackage[titles]{tocloft}
\RequirePackage{mathtools,amsthm,amsfonts,amssymb,bm}
\RequirePackage[defaultsups]{newtxtext}
\RequirePackage{newtxmath}
\RequirePackage[opentype]{sourcecodepro}
\RequirePackage{upgreek}
\RequirePackage{wasysym}
\RequirePackage{anyfontsize}
\RequirePackage{metalogo,doc}
\RequirePackage{array}
\RequirePackage{threeparttable}
\RequirePackage{dcolumn}
\RequirePackage{multirow}
\RequirePackage{booktabs}
\RequirePackage{graphicx}
\RequirePackage{caption}
\RequirePackage[list=off]{bicaption}
\RequirePackage{subcaption}
\RequirePackage[backend=biber,style=gb7714-2015]{biblatex}
\RequirePackage{xcolor}
\RequirePackage{textcomp}
\RequirePackage[xetex, bookmarksnumbered, colorlinks, urlcolor=black, linkcolor=black, citecolor=black, plainpages=false, pdfstartview=FitH]{hyperref}
\RequirePackage{longtable}
\RequirePackage[perpage, bottom]{footmisc}
\RequirePackage[inline]{enumitem}
\RequirePackage{pdfpages}
\RequirePackage{calc}
\RequirePackage{algorithm, algorithmicx, algpseudocode}
\RequirePackage{siunitx}
\RequirePackage{tikz}
\RequirePackage{imakeidx}
\makeindex



\begin{document}

\hypertarget{chap:pandocchapter}{%
\section{\texorpdfstring{Test pandoc\index{pandoc}
chapter}{Test pandoc chapter}}\label{chap:pandocchapter}}

\hypertarget{test-pandoc}{%
\section{\texorpdfstring{Test
pandoc\index{pandoc} {#chap:pandoc}}{Test pandoc}}\label{test-pandoc}}
\printindex

\end{document}

the output I expected instead

\documentclass{ctexbook}

\RequirePackage{etoolbox}
\RequirePackage[centering,a4paper,body={16cm,22cm}]{geometry} %设置版面
\RequirePackage{fancyhdr}
\RequirePackage{pageslts}
\RequirePackage[titles]{tocloft}
\RequirePackage{mathtools,amsthm,amsfonts,amssymb,bm}
\RequirePackage[defaultsups]{newtxtext}
\RequirePackage{newtxmath}
\RequirePackage[opentype]{sourcecodepro}
\RequirePackage{upgreek}
\RequirePackage{wasysym}
\RequirePackage{anyfontsize}
\RequirePackage{metalogo,doc}
\RequirePackage{array}
\RequirePackage{threeparttable}
\RequirePackage{dcolumn}
\RequirePackage{multirow}
\RequirePackage{booktabs}
\RequirePackage{graphicx}
\RequirePackage{caption}
\RequirePackage[list=off]{bicaption}
\RequirePackage{subcaption}
\RequirePackage[backend=biber,style=gb7714-2015]{biblatex}
\RequirePackage{xcolor}
\RequirePackage{textcomp}
\RequirePackage[xetex, bookmarksnumbered, colorlinks, urlcolor=black, linkcolor=black, citecolor=black, plainpages=false, pdfstartview=FitH]{hyperref}
\RequirePackage{longtable}
\RequirePackage[perpage, bottom]{footmisc}
\RequirePackage[inline]{enumitem}
\RequirePackage{pdfpages}
\RequirePackage{calc}
\RequirePackage{algorithm, algorithmicx, algpseudocode}
\RequirePackage{siunitx}
\RequirePackage{tikz}
\RequirePackage{imakeidx}
\makeindex



\begin{document}

\hypertarget{chap:pandocchapter}{%
\section{\texorpdfstring{Test pandoc\index{pandoc}
chapter}{Test pandoc chapter}}\label{chap:pandocchapter}}

\hypertarget{test-pandoc}{%
\section{\texorpdfstring{Test
pandoc\index{pandoc}}{Test pandoc}}\label{chap:pandoc}}
\printindex

\end{document}

If \index located at the end of chapter name, it cannot produce as expected. Thank you.

@mb21
Copy link
Collaborator

mb21 commented Jul 10, 2018

You are saying that in

echo '# Test pandoc\index{pandoc} {id="chap:pandoc"}' | pandoc -t latex

the markdown attribute is not being picked up?

Try the following, which uses a raw attribute:

echo '# `Test pandoc\index{pandoc}`{=latex} {id="chap:pandoc"}' | pandoc -t latex

Not saying the latex in markdown parser could not be improved, but I this is a reasonable workaround.

@bubifengyun
Copy link
Author

it seems that it cannot show in contents. The output is

\hypertarget{chap:pandoc}{%
\section{\texorpdfstring{Test pandoc\index{pandoc}}{}}\label{chap:pandoc}}

I think it should be

\hypertarget{chap:pandoc}{%
\section{\texorpdfstring{Test pandoc\index{pandoc}}{Test pandoc}}\label{chap:pandoc}}

@bubifengyun
Copy link
Author

I decide use another bad method, put index in the front of text, such as

Test \index{pandoc}pandoc {id="chap:pandoc"}

now it can works well.

@jgm
Copy link
Owner

jgm commented Jul 12, 2018 via email

@bubifengyun
Copy link
Author

Thank you. I think changeing the \index location is easy. I would adopt it. Add others' thing would make paper not beautiful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants