我有一个 URL,它被换行符打断了。理想情况下,我希望能够复制整个 wget 命令并将其粘贴到终端中。不幸的是,我最终得到了一个溢出的框和多个片段。
\documentclass[12pt]{article}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{float}
\usepackage[margin=1.2in]{geometry}
\usepackage{graphicx}
\graphicspath{ {./images/} }
\usepackage[colorlinks = true,
linkcolor = blue,
urlcolor = blue,
citecolor = blue,
anchorcolor = blue]{hyperref}
\urlstyle{same}
\newcommand{\MYhref}[3][blue]{\href{#2}{\color{#1}{#3}}}%
\usepackage{listings, lstautogobble, xcolor, beramono}
\usepackage{tikz}
\lstset{
basicstyle=\small\ttfamily,
columns=flexible,
breaklines=true,
breakatwhitespace=false,
backgroundcolor=\color{blue!20},
showstringspaces=false,
frameround=ffff,
frame=single,
rulecolor=\color{black},
autogobble=true}
\lstset{
emph=[1]{%
wget, gunzip, cd, docker, grep, cut, sort, export%
},emphstyle=[1]{\color{red}\bfseries},%
emph=[2]{%
run, -f, -n, -o, -t, -k, -j, -q, -v%
},emphstyle=[2]{\color{orange}\bfseries},%
emph=[3]{%
--mount, --workdir, -e%
},emphstyle=[3]{\color{purple}\bfseries},%
emph=[4]{%
Salmo\_salar.ICSASG\_v2.dna.toplevel.fa.gz, Salmo\_salar.ICSASG\_v2.dna.toplevel.fa, Salmo\_salar.ICSASG\_v2.dna.toplevel.fa.fai,
Ssal\_chrm.txt
},emphstyle=[4]{\color{blue}\bfseries},%
emph=[5]{%
juettemann\/samtools:latest, juettemann/genrich:1.0%
},emphstyle=[5]{\color{brown}\bfseries},%
}%
\lstdefinelanguage{mylang}{ %
% keywords={FOO,BAR,BAZ,ARG}, %
% otherkeywords={1234,XYZ1234,XYZ1234HelloWorld}, %
alsoletter=.\_-/:,
}%
\begin{lstlisting}[language=mylang]
cd $dir_atac/ref_genome
wget http://ftp.ensembl.org/pub/release-103/fasta/salmo_salar/dna/Salmo_salar.ICSASG_v2.dna.toplevel.fa.gz
gunzip Salmo_salar.ICSASG_v2.dna.toplevel.fa.gz
\end{lstlisting}
答案1
根据评论部分 Ulrike Fischer 的建议,accsupp 是解决方案。我添加了以下说明: https://www.monperrus.net/martin/copy-pastable-listings-in-pdf-from-latex,现在可以正常工作了。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{listings}
\lstset{
upquote=true,
columns=fullflexible,
basicstyle=\ttfamily,
literate={*}{{\char42}}1
{-}{{\char45}}1
{\ }{{\copyablespace}}1
}
\usepackage[space=true]{accsupp}
\newcommand{\copyablespace}{\BeginAccSupp{method=hex,unicode,ActualText=00A0}\hphantom{x}\EndAccSupp{}}
我只是偶尔使用乳胶,我对该系统的理解还不够深入,无法解释它的作用。