latex - 如何在 LaTex 中为引用添加前缀?
问题描述
所以我有这样的数字:
\begin{figure}[h]{}
\includegraphics[width=\textwidth]{./assets/demo/identify-usecases/DomainSplitt-1.jpg}
\caption{Identifying Domains: Match History with Filter}
\centering
\label{fig:domainsplitt-one}
\end{figure}
我这样引用它们:\ref{fig:domainsplitt-one}
.
在生成的 PFD 中,图像具有这样的标题Figure 4.13: Identifying Domains: Match History with Filter
。但文中的参考只有数字4.13
。
我有类似的代码:
\begin{code}
\captionof{listing}{Custom Element listening to global custom events}
\label{code:listening-custom-event}
\begin{minted}{JavaScript}
在这里,代码有前缀Source Code
,但参考中只有数字。我使用的规则是
\usepackage[newfloat]{minted}
\usepackage{caption}
\newenvironment{code}{\captionsetup{type=listing}}{}
\SetupFloatingEnvironment{listing}{name=Source Code}
所以我需要的是,参考在文本中也有这个前缀。由于我对乳胶真的很陌生,可能会问:我该怎么做?
编辑:这里是一个副本的链接: https ://github.com/adrian-goe/latex-replica
解决方案
该cleveref
软件包将为您完成所有工作:
% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}
% Preamble
%\documentclass[11pt]{article}
% Packages
\documentclass[12pt,DIV12,BCOR0mm,twoside,openright,headings=normal, numbers=noenddot,headsepline,headinclude]{scrreprt}
\usepackage[automark,headsepline]{scrlayer-scrpage}
\usepackage{scrhack} % to avoid KOMA-Script warning
\usepackage[utf8]{inputenc} % UTF8 encoding
\usepackage[T1]{fontenc}
\usepackage{txfonts} % Postscript fonts
\usepackage[ngerman,english]{babel}
\usepackage[style=numeric-comp,giveninits=true,maxnames=10,sorting=none]{biblatex}
\usepackage{graphicx}
\usepackage[usenames]{xcolor}
\usepackage[pdftex]{hyperref}
\usepackage{wallpaper}
\usepackage[newfloat]{minted}
\usepackage{caption}
\newenvironment{code}{\captionsetup{type=listing}}{}
\SetupFloatingEnvironment{listing}{name=Code}
\usemintedstyle{manni}
\usepackage[noabbrev]{cleveref}
\crefname{listing}{code}{code}
\Crefname{listing}{Code}{Code}
% Document
\begin{document}
this is my sample text and i want to reference \cref{code:update-a-attribute} and the \cref{fig:image}
\begin{figure}[h]{}
\includegraphics[width=\textwidth]{./img.png}
\caption{some image}
\centering
\label{fig:image}
\end{figure}
\begin{code}
\captionof{listing}{Update a Attribute}
\label{code:update-a-attribute}
\begin{minted}{JavaScript}
const fragment = document.querySelector(".fragment");
fragment.setAttribute("data", 2)
\end{minted}
\end{code}
\end{document}
(请注意,您只能拥有一个文档类)
推荐阅读
- python - 如何使用 beautiful-soup 从网站中提取数据?
- sql - 在sql表的列中添加连字符
- php - 将 PHP 请求路由到 App Engine 中的子文件夹
- reactjs - Getting undefined while accessing Context values
- power-automate - 我的 MS-Flow 中的“添加动态内容”窗口在哪里?
- python-3.x - Python 和 Opencv:我无法连接到相机 ip Ezviz C6CN
- android - 如何在 Android 上从 Firebase 查询数据
- input - 有没有办法将控制台应用程序的输入/输出连接到另一个程序的输出/输入
- sql-server - SQL Pivot 基于字符串值而不是数字
- python - 如何通过循环遍历python嵌套字典来创建一个html表