-
Notifications
You must be signed in to change notification settings - Fork 84
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
使用 quarto 生成 pdf 参考文献的等字显示为 “andotherscn” #204
Comments
是不是应该还有一个 cite-style? 我没用过这个quarto ,有个疑问,为什么biblatex不和amsthm等一样的用法呢? 使用usepackage? |
比如直接用:
|
quarto 的 cite-method 有 citeproc, natbib, or biblatex这三个 可以把 include-in-header:
text: |
\usepackage{ctex}
\usepackage{amsthm,mathrsfs}
\usepackage{arydshln}
\usepackage[sort&compress]{gbt7714}
cite-method: natbib
biblio-style: gbt7714-numerical 能用了,就是上标和正文需要 |
你能把使用biblatex时的信息给的更全面一些么? 你最好打个包,告诉我怎么复现这样一个问题。 |
我猜,虽然使用了biblatex,但没有使用biber,所以应该给出biblatex的backend选项。 就是 https://quarto.org/docs/output-formats/pdf-basics.html 里面提的 或者直接使用:
|
quarto 使用 pandoc 导出 tex 文件,然后编译tex的log是这样的 Rendering PDF
running xelatex - 1
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
generating bibliography
INFO - This is Biber 2.19
INFO - Logfile is '1_copy.blg'
INFO - Reading '1_copy.bcf'
INFO - Found 3 citekeys in bib section 0
INFO - Processing section 0
INFO - Looking for bibtex file 'references.bib' for section 0
INFO - LaTeX decoding ...
INFO - Found BibTeX data source 'references.bib'
INFO - Overriding locale 'chinese-hans' defaults 'normalization = NFD' with 'normalization = prenormalized'
INFO - Overriding locale 'chinese-hans' defaults 'variable = shifted' with 'variable = non-ignorable'
INFO - Sorting list 'none/global//global/global' of type 'entry' with template 'none' and locale 'chinese-hans'
INFO - No sort tailoring available for locale 'chinese-hans'
INFO - Writing '1_copy.bbl' with encoding 'UTF-8'
INFO - Output to 1_copy.bbl
running xelatex - 2
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
running xelatex - 3
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode 用 tinytex 是一样的效果 Rendering PDF
running xelatex - 1
This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
generating bibliography
INFO - This is Biber 2.20
INFO - Logfile is '1_copy.blg'
INFO - Reading '1_copy.bcf'
INFO - Found 3 citekeys in bib section 0
INFO - Processing section 0
INFO - Looking for bibtex file 'references.bib' for section 0
INFO - LaTeX decoding ...
INFO - Found BibTeX data source 'references.bib'
INFO - Overriding locale 'chinese-hans' defaults 'variable = shifted' with 'variable = non-ignorable'
INFO - Overriding locale 'chinese-hans' defaults 'normalization = NFD' with 'normalization = prenormalized'
INFO - Sorting list 'none/global//global/global/global' of type 'entry' with template 'none' and locale 'chinese-hans'
INFO - No sort tailoring available for locale 'chinese-hans'
INFO - Writing '1_copy.bbl' with encoding 'UTF-8'
INFO - Output to 1_copy.bbl
running xelatex - 2
This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
running xelatex - 3
This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
Output created: 1_copy.pdf |
生成 tex 是这样的 % Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
a4paper,
]{article}
\usepackage{amsmath,amssymb}
\usepackage{setspace}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else
% xetex/luatex font selection
\setmonofont[]{Consolas}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\usepackage{xcolor}
\usepackage[top=1in,left=1.25in,heightrounded]{geometry}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{5}
% Make \paragraph and \subparagraph free-standing
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\usepackage{ctex}
\usepackage{amsthm,mathrsfs}
\usepackage{arydshln}
\newcommand{\n}{\\}
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\AtBeginDocument{%
\ifdefined\contentsname
\renewcommand*\contentsname{目录}
\else
\newcommand\contentsname{目录}
\fi
\ifdefined\listfigurename
\renewcommand*\listfigurename{图索引}
\else
\newcommand\listfigurename{图索引}
\fi
\ifdefined\listtablename
\renewcommand*\listtablename{表索引}
\else
\newcommand\listtablename{表索引}
\fi
\ifdefined\figurename
\renewcommand*\figurename{图}
\else
\newcommand\figurename{图}
\fi
\ifdefined\tablename
\renewcommand*\tablename{表}
\else
\newcommand\tablename{表}
\fi
}
\@ifpackageloaded{float}{}{\usepackage{float}}
\floatstyle{ruled}
\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
\floatname{codelisting}{列表}
\newcommand*\listoflistings{\listof{codelisting}{列表索引}}
\makeatother
\makeatletter
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\@ifpackageloaded{subcaption}{}{\usepackage{subcaption}}
\makeatother
\makeatletter
\@ifpackageloaded{tcolorbox}{}{\usepackage[skins,breakable]{tcolorbox}}
\makeatother
\makeatletter
\@ifundefined{shadecolor}{\definecolor{shadecolor}{rgb}{.97, .97, .97}}{}
\makeatother
\makeatletter
\@ifundefined{codebgcolor}{\definecolor{codebgcolor}{HTML}{f1f3f5}}{}
\makeatother
\makeatletter
\ifdefined\Shaded\renewenvironment{Shaded}{\begin{tcolorbox}[sharp corners, boxrule=0pt, colback={codebgcolor}, frame hidden, breakable, enhanced]}{\end{tcolorbox}}\fi
\makeatother
\ifLuaTeX
\usepackage[bidi=basic]{babel}
\else
\usepackage[bidi=default]{babel}
\fi
\babelprovide[main,import]{chinese-hans}
% get rid of language-specific shorthands (see #6817):
\let\LanguageShortHands\languageshorthands
\def\languageshorthands#1{}
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\usepackage[style=gb7714-2015,backend = biber]{biblatex}
\addbibresource{references.bib}
\usepackage{bookmark}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
pdflang={zh-Hans},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\author{}
\date{2024-05-23}
\begin{document}
\renewcommand*\contentsname{目录}
{
\setcounter{tocdepth}{3}
\tableofcontents
}
\setstretch{1.5}
\newpage{}
\section{问题背景}\label{ux95eeux9898ux80ccux666f}
文献\autocite{孙国强2021基于双层}。文献\autocite{符杨2022基于主从博弈的微电网群多阶段鲁棒优化规划}。文献\autocite{saravanan2013solution}。
\newpage{}
\printbibliography[title=参考文献]
\end{document}
|
这个问题应该是你在 \ifLuaTeX
\usepackage[bidi=basic]{babel}
\else
\usepackage[bidi=default]{babel}
\fi
\babelprovide[main,import]{chinese-hans}
% get rid of language-specific shorthands (see #6817):
\let\LanguageShortHands\languageshorthands
\def\languageshorthands#1{} 不确定是不是这几行代码对 biblatex-gb7714-2015 判断中文造成了影响。 个人建议,在使用 Pandoc 或 Quarto 时,尽量不要设置 |
感谢,这个解释很清楚了。 |
谢谢你们,确实是这个问题 |
单独找到语言配置文件后设置,可以在支持中文同时避免了生成有冲突的代码。 language: _language-zh.yml
|
autocite命令本来设计的就跟autocite选项相关,默认选项是inline,所以 所以当设置autocite为不同选项时,要修改不同的格式就要修改对应的命令。 |
可以参考这个 issue 中提供的 workaround: jgm/pandoc#3811 |
好的,谢谢。已经达到我想要的样子了。目前来看,我只能用 quarto 写一下课程作业。对格式要求再高一点,我得特别头大了。 |
Pandoc/Quarto 写中文论文确实需要很多调整,不过还是可以胜任中文毕业论文这种格式刁钻的要求的。我最近就在用 Quarto 写论文,通过自定义模板和 Lua filters,目前已解决了绝大部分问题,基本上可以实现直接生成排版完美的 DOCX/HTML/PDF 文件,后面我有时间了来分享一下。 |
include-in-header:
text: |
\usepackage{ctex}
\usepackage{amsthm,mathrsfs}
\usepackage{arydshln}
\newcommand{\n}{\\}
include-before-body:
text: |
\renewcommand{\textcite}{\parencite}
cite-method: biblatex
biblio-style: gb7714-2015
biblatexoptions:
- autocite = plain |
@jchliao 我的 Quarto 项目开源了,欢迎使用,目前还很不完善,特别是使用说明,欢迎提交 Issue 和 PR:https://github.com/TomBener/quarto-cn-tools |
使用 quarto 生成 pdf 参考文献的等字显示为 “andotherscn”
yaml配置
The text was updated successfully, but these errors were encountered: