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

用法:修改斜杠字符的字体族和调整括号的垂直位置 #144

Open
note286 opened this issue Jun 25, 2022 · 10 comments
Open

用法:修改斜杠字符的字体族和调整括号的垂直位置 #144

note286 opened this issue Jun 25, 2022 · 10 comments

Comments

@note286
Copy link

note286 commented Jun 25, 2022

gb7714-2015.bbx中,我发现所有的斜杠都是打字机字体族,例如析出来源文献前的//符号,还有其他的例如D/OL等。

我想要整个参考文献列表均为罗马族字体的时候发现了这个问题。这些斜杠如果是打字机字体族会显得很宽,很突兀。

另外,问一下,默认把斜杠的字体族写死成打字机字体族是出于什么考量呢?

@hushidong
Copy link
Owner

应该是为了美观,和搭配好看。有点忘了是不是讨论过。
normal字体似乎有点偏细偏长。最早的时候选择了texttt一直也没有人提出需求,所以也没动过。

看下面图中的框
图片

你可以试着比较一下看看,看用什么更好,更美观,分享一下。

暂时先修改宏把,等后面充分讨论了,可以加接口控制。

\documentclass[]{ctexart}%文档类%导言区开始:

\usepackage[backend=biber,style=gb7714-2015]{biblatex}%标注(引用)样式citestyle,著录样式bibstyle都采用gb7714-2015样式

\renewbibmacro*{in:}{%
 \iftoggle{bbx:gbpunctin}{\printtext{\allowbreak//\allowbreak}}%\addthinspace
                         {\setunit{\adddot\addspace}%
                         \iffieldequalstr{userd}{chinese}%
                         {\printtext{\bibstring{incn}}}%
                         {\printtext{\bibstring{in}}}%
                         }}%\newunit\newblock\intitlepunct

\DeclareFieldFormat{gbtypeflag}{%
\iftoggle{bbx:gbmedium}%
{\iftoggle{bbx:url}%
    {\iffieldundef{url}%当存在url时,增加一个OL标识符
        {\allowbreak\printtext{[}\nobreak#1\nobreak\printtext{\iffieldundef{medium}{}{/\thefield{medium}}]}}%
        {\allowbreak\printtext{[}\nobreak#1\nobreak\printtext{/OL]}}%
    }%
    {\ifentrytype{online}%
        {\allowbreak\printtext{[}\nobreak#1\nobreak\printtext{/OL]}}%
        {\allowbreak\printtext{[}\nobreak#1\nobreak\printtext{\iffieldundef{medium}{}{/\thefield{medium}}]}}%
    }}%
    {\allowbreak\printtext{[}\nobreak#1\nobreak\printtext{]}}%
}


\DeclareFieldFormat{gbtypeflagn}{%用于报纸newspaper
\iftoggle{bbx:gbmedium}%
{\iftoggle{bbx:url}%
    {\iffieldundef{url}%当存在url时,增加一个OL标识符
        {\allowbreak\printtext{[}\nobreak N\printtext{\iffieldundef{medium}{}{/\thefield{medium}}]}\nobreak}%
        {\allowbreak\printtext{[}\nobreak N\printtext{/OL]}\nobreak}%
    }%
    {\allowbreak\printtext{[}\nobreak N\printtext{\iffieldundef{medium}{}{/\thefield{medium}}]}\nobreak}%
}{\allowbreak\printtext{[}\nobreak N\printtext{]}\nobreak}%
}

\DeclareFieldFormat{gbtypeflags}{%用于标准standard
\iftoggle{bbx:gbmedium}%
{\iftoggle{bbx:url}%
    {\iffieldundef{url}%当存在url时,增加一个OL标识符
        {\allowbreak\printtext{[}\nobreak S\printtext{\iffieldundef{medium}{}{/\thefield{medium}}]}\nobreak}%
        {\allowbreak\printtext{[}\nobreak S\printtext{/OL]}\nobreak}%
    }%
    {\allowbreak\printtext{[}\nobreak S\printtext{\iffieldundef{medium}{}{/\thefield{medium}}]}\nobreak}%
}{\allowbreak\printtext{[}\nobreak S\printtext{]}\nobreak}%
}


\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inbook{杨国枢rawtypea,
  author       = {杨国枢},
  title        = {中国人对现代化的反应:心理学的观点},
  editor   = {乔健},
  booktitle    = {中国人的观念与行为},
  location     = {天津},
  publisher    = {天津人民出版社},
  year         = {1995},
  pages        = {209-239},
}


@inbook{Morisonrawtype,
  author       = {James I L Morison},
  title        = {Intercellular $\mathrm{CO}_2$ concentration and stomatal responses to $\mathrm{CO}_2$},
  editor       = {Eduardo Zeiger and Eduardo Zeiger and Eduardo Zeiger and Eduardo Zeiger},
  editortype   ={editor},
  booktitle    = {Stomatal Function},
  location     = {Stanford},
  publisher    = {Stanford University Press},
  year         = {1987},
  pages        = {229-251}
}

@online{萧钮CCNUtype,
  author          = {萧钮},
  title           = {出版业信息化迈入快车道},
  year            = {2001-12-19},
  urldate         = {2002-04-15},
  url             = {http://www.creader.com/news/20011219/200112190019.html}
}

\end{filecontents}

\addbibresource[location=local]{\jobname.bib}%biblatex宏包的参考文献数据源加载方式

\begin{document}%正文区开始:

\nocite{*}

%打印参考文献表
\printbibliography[heading=bibliography,title=参考文献]

\end{document} 

@note286
Copy link
Author

note286 commented Jun 25, 2022

非常感谢你的回答,由于实际写作中参考文献里不会出现打字机族字体,作为临时解决办法,目前我直接在输出文献列表前,在分组内,将\texttt置空了,这样就恢复到了默认的罗马族字体。代码也比较整洁。


某些打字机族字体,例如TeX Gyre Cursor,会显得很宽,一眼看上去很突兀,否则我也不会意识到这里的字体是不同的了。对于你说的高度问题,相较于打字机字体族的过宽问题,罗马族字体高度问题反而不那么突兀了。因此,我觉得有必要提供一个接口,允许用户修改。这个接口也比较容易添加。

image


另外,有个问题有点类似,我一直有些许困扰于英文方括号(圆括号亦如此)的垂直位置,例如在参考文献数字引用时,由于数字没有在基线下的部分,会导致方括号相较于引用数字是偏下的,相较于中文也是如此,一直找不到合适的方法在这方面处于美观进行调整。

image

@hushidong
Copy link
Owner

关于这个括号高度上对齐的问题,实话说我不太熟悉,我理解可以有不同的处理方式:

  1. 是全局的字体的处理,如果某个字体本身就比较好,用就行了,如果字体本身就这样的情况,那能否将部分字体进行调整,使得字体本身就能解决该问题。

  2. 是局部的在biblatex这边处理,将这些个符号设单独置为某些比较合适的字体。

  3. 也是局部的在biblatex这边处理,字体还是使用统一的字体,但在使用这些符号时,利用盒子移动稍微移动一下。这个问题,我后面看看能用比较简单的接口方式来,统一的调整一下。原来这里面内容是比较碎的,有的时候用biblatex提供的宏,有的直接写,要统一处理,我还要仔细梳理一下。

你也可以尝试其它方式,试试看,或者问问其它人,特别是ctex论坛上面字体方面的高手,他们可能会有一些很简单的方案。
你看有没有好的方案,可以分享一下。

关于斜杠字体,后面会增加一个命令\SlashFont来控制:比如:
\def\SlashFont{\rmfamily}这样的设置,直接对其进行设置。

@note286
Copy link
Author

note286 commented Jun 25, 2022

关于斜杠的处理方法是不错的,如果添加后能at我一下就非常感谢了。

关于括号高度问题,方法1和方法2都需要寻找字体,某些时候可能会不满足某些场合关于字体的要求。不过方法1和2也是可以接受的。方法3是我尝试过的,可以通过\kern等操作实现,但是会产生一个问题,对于括号前后有中文的情况,由于括号被抬升了,因此ctex无法识别括号为英文字符,无法正确在括号和中文中间插入空白。是否有一种方式可以使得某个字符为0宽度,这样先插入一个0宽度括号,再插入一个抬升的括号,这个思路可以规避这个问题,但是我不知道是否可行。

@hushidong
Copy link
Owner

已经加了,见最新的更新。

方括号和圆括号也做了调整。

\renewcommand*{\bibleftparen}{\blx@postpunct\raise0.2ex\hbox{(}}
\renewcommand*{\bibrightparen}{\blx@postpunct\raise0.2ex\hbox{)}\midsentence}
\renewcommand*{\bibleftbracket}{\blx@postpunct\raise0.2ex\hbox{[}}
\renewcommand*{\bibrightbracket}{\blx@postpunct\raise0.2ex\hbox{]}\midsentence}
\newcommand*{\gbleftparen}{\raise0.2ex\hbox{(}}
\newcommand*{\gbrightparen}{\raise0.2ex\hbox{)}}
\newcommand*{\gbleftbracket}{\raise0.2ex\hbox{[}}
\newcommand*{\gbrightbracket}{\raise0.2ex\hbox{]}}

我加高了0.2的比例,0.15的比例也可以看着还行,你可以试试看。

图片

\documentclass[]{ctexart}%文档类%导言区开始:

\usepackage[backend=biber,style=gb7714-2015]{biblatex}%标注(引用)样式citestyle,著录样式bibstyle都采用gb7714-2015样式

\def\SlashFont{\rmfamily}
\makeatletter
\renewcommand*{\bibleftparen}{\blx@postpunct\raise0.15ex\hbox{(}}
\renewcommand*{\bibrightparen}{\blx@postpunct\raise0.15ex\hbox{)}\midsentence}
\renewcommand*{\bibleftbracket}{\blx@postpunct\raise0.15ex\hbox{[}}
\renewcommand*{\bibrightbracket}{\blx@postpunct\raise0.15ex\hbox{]}\midsentence}
\renewcommand*{\gbleftparen}{\raise0.15ex\hbox{(}}
\renewcommand*{\gbrightparen}{\raise0.15ex\hbox{)}}
\renewcommand*{\gbleftbracket}{\raise0.15ex\hbox{[}}
\renewcommand*{\gbrightbracket}{\raise0.15ex\hbox{]}}
\makeatother

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inbook{杨国枢rawtypea,
  author       = {杨国枢},
  title        = {中国人对现代化的反应:心理学的观点},
  editor   = {乔健},
  booktitle    = {中国人的观念与行为},
  location     = {天津},
  publisher    = {天津人民出版社},
  year         = {1995},
  pages        = {209-239},
}


@inbook{Morisonrawtype,
  author       = {James I L Morison},
  title        = {Intercellular $\mathrm{CO}_2$ concentration and stomatal responses to $\mathrm{CO}_2$},
  editor       = {Eduardo Zeiger and Eduardo Zeiger and Eduardo Zeiger and Eduardo Zeiger},
  editortype   ={editor},
  booktitle    = {Stomatal Function},
  location     = {Stanford},
  publisher    = {Stanford University Press},
  year         = {1987},
  pages        = {229-251}
}

@online{萧钮CCNUtype,
  author          = {萧钮},
  title           = {出版业信息化迈入快车道},
  year            = {2001-12-19},
  urldate         = {2002-04-15},
  url             = {http://www.creader.com/news/20011219/200112190019.html}
}

\end{filecontents}

\addbibresource[location=local]{\jobname.bib}%biblatex宏包的参考文献数据源加载方式

\begin{document}%正文区开始:

中文\cite{杨国枢rawtypea}

中文\parencite{Morisonrawtype}

中文\textcite{萧钮CCNUtype}


%打印参考文献表
\printbibliography[heading=bibliography,title=参考文献]

\end{document} 

@note286
Copy link
Author

note286 commented Jun 26, 2022

\SlashFont好评。


另外,对于括号垂直抬升的调整,建议留一个接口,默认不更改,用户可以选择更改,同时提供一个抬升高度的变量,允许用户覆盖值,这样就完美了。

目前发现的问题是,在参考文献列表中抬升效果还不错。不过遇到[M]//这种情况,如果括号抬升,斜杠不抬升就怪怪的(当然可以继续让斜杠使用打字机族字体),如果斜杠也抬升,但是如果同一行后面出现了网址,就会导致前后斜杠高度不一致,除非所有的斜杠也都抬升,所以括号抬升目前只能作为实验性的调整,默认不抬升,给用户选择,是最稳妥的。

另外一个问题是,在正文引用中,\textcite的括号是抬升的,\cite\parencite是不抬升的,我不是很了解内部逻辑,所以不知道这是为什么。


最后,说一下我为什么有这个抬升这个想法,一开始是写英文论文的时候,大部分都是小写字母,都在基线上,然而括号一直都是视觉上下沉的,很不美观,而且行文中几乎不会用到方括号,因此把数字引用的方括号抬升一点是美观的。

@hushidong
Copy link
Owner

之前没有更新标注样式,现在又更新了一下。

括号的提升用一个尺寸 \BracketLift控制。

比如:

\documentclass[]{ctexart}%文档类%导言区开始:

\usepackage[backend=biber,style=gb7714-2015]{biblatex}%标注(引用)样式citestyle,著录样式bibstyle都采用gb7714-2015样式

\def\UrlFont{\ttfamily}
\def\SlashFont{\ttfamily}
\setlength{\BracketLift}{0.15ex}


\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inbook{杨国枢rawtypea,
  author       = {杨国枢},
  title        = {中国人对现代化的反应:心理学的观点},
  editor   = {乔健},
  booktitle    = {中国人的观念与行为},
  location     = {天津},
  publisher    = {天津人民出版社},
  year         = {1995},
  pages        = {209-239},
}


@inbook{Morisonrawtype,
  author       = {James I L Morison},
  title        = {Intercellular $\mathrm{CO}_2$ concentration and stomatal responses to $\mathrm{CO}_2$},
  editor       = {Eduardo Zeiger and Eduardo Zeiger and Eduardo Zeiger and Eduardo Zeiger},
  editortype   ={editor},
  booktitle    = {Stomatal Function},
  location     = {Stanford},
  publisher    = {Stanford University Press},
  year         = {1987},
  pages        = {229-251}
}

@online{萧钮CCNUtype,
  author          = {萧钮},
  title           = {出版业信息化迈入快车道},
  year            = {2001-12-19},
  urldate         = {2002-04-15},
  url             = {http://www.creader.com/news/20011219/200112190019.html}
}

\end{filecontents}

\addbibresource[location=local]{\jobname.bib}%biblatex宏包的参考文献数据源加载方式

\begin{document}%正文区开始:

中文\cite{杨国枢rawtypea}

中文\parencite{Morisonrawtype}

中文\textcite{萧钮CCNUtype}


%打印参考文献表
\printbibliography[heading=bibliography,title=参考文献]

\end{document} 

@hushidong hushidong changed the title 能否增加接口允许修改斜杠字符的字体族 修改斜杠字符的字体族和调整括号的垂直位置 Jun 26, 2022
@note286
Copy link
Author

note286 commented Jun 26, 2022

测试了,很棒,还是之前提到的一个问题。在正文引用中,\textcite的括号是抬升的,\cite\parencite是不抬升的,我不是很了解内部逻辑,所以不知道这是为什么。

@hushidong
Copy link
Owner

cbx文件也更新一下,现在应该已经好了的。

@note286
Copy link
Author

note286 commented Jun 26, 2022

非常感谢,期待CTAN的更新。

@note286 note286 closed this as completed Jun 26, 2022
@hushidong hushidong changed the title 修改斜杠字符的字体族和调整括号的垂直位置 用法:修改斜杠字符的字体族和调整括号的垂直位置 May 27, 2023
@hushidong hushidong reopened this May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants