I have an environment which I specify w/...
\begin{code}{TITLE}{LANGUAGE}{CAPTION}
\end{code}
I'd like be able to specify it instead like...
\begin{code}[title={TITLE},language={LANGUAGE},caption={CAPTION}]
\end{code}
A current example for the environment is...
\documentclass{article}
\usepackage[most]{tcolorbox}
\tcbuselibrary{listings, breakable, skins}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[T1]{fontenc}
\usepackage[ttdefault=true]{AnonymousPro}
\usepackage{fontawesome5}
\renewcommand*\thelstnumber{\makebox[3em][r]{\ifnum\value{lstnumber}<10 0\fi\the\value{lstnumber}}}
% line numbers and white space
\usepackage[space=true]{accsupp}
% create non-copy numbers (source - https://tex.stackexchange.com/a/57160)
\newcommand{\copyablespace}{\BeginAccSupp{method=hex,unicode,ActualText=00A0}\hphantom{x}\EndAccSupp{}}
% copy-able whitespace (source - https://tex.stackexchange.com/a/142765)
\newcommand\donotcopy[1]{% line number printing mechanism
\BeginAccSupp{ActualText={}}#1\EndAccSupp{}%
}
\definecolor{pblue}{rgb}{0.13,0.13,1}
\definecolor{pgreen}{rgb}{0,0.5,0}
\newtcblisting[auto counter]{code}[4][]{
enhanced,
top=\smallskipamount,
bottom=\smallskipamount,
sharp corners=downhill,
arc=0.5cm,
colframe=gray!20,
attach boxed title to top left={
% yshift=-\tcboxedtitleheight - \smallskipamount,
xshift=-2mm
},
boxed title style={
size=small,
colback=white,
colframe=white,
boxrule=0pt,
top=0pt,
bottom=0pt,
right=0pt,
left=0pt
},
fonttitle=\color{black},
overlay={
\begin{tcbclipinterior}
\fill[gray!25](frame.south west)
rectangle ([xshift=5.0mm]frame.north west);
\end{tcbclipinterior}
\node[inner sep=0.75mm, rounded corners=0.5mm, anchor=north east, ,fill=gray!50] at ([xshift=-2.5mm, yshift=\baselineskip]frame.south east){\scriptsize\color{violet}\itshape\ttfamily#2};
},
listing only,
listing options={
numbers=left,
numberstyle=\ttfamily\tiny\donotcopy,
captionpos=t,
abovecaptionskip=0pt,
belowcaptionskip=\medskipamount,
language=#3,
xleftmargin=0.5em,
basicstyle=\fontfamily{AnonymousPro}\selectfont,
keywordstyle=\bfseries\color{pblue},
stringstyle=\bfseries\itshape\color{green!40!black},
commentstyle=\bfseries\itshape\color{black!60},
showspaces=false,
showtabs=false,
breaklines=true,
showstringspaces=false,
tabsize=1,
emphstyle={\bfseries\color{pblue}},
columns=fullflexible,
literate={\ }{{\copyablespace}}1,
},
title=\ifx #4\empty\empty\else\ \textbf{Code Snippet~\thetcbcounter.} #4\fi,
#1
}
\setlength\parindent{0pt}
\begin{document}
\begin{code}{\faJava \ \raisebox{0.1\height}{Hello.Java}}{Java}{A Java Example.}
String s = "Hello World";
Animation from_top = AnimationUtils.loadAnimation(this, R.anim.from_top);
imageView.setAnimation(from_top);
// change activity with fade animation
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
startActivity(intent);
overridePendingTransition(R.anim.fade_in,R.anim.fade_out);
finish();
}
}, SPLASH_TIMEOUT);
\end{code}
\end{document}
newtcblistingand the nestedlisting options)? I think its easier to define two optional arguments of which one gets append tonewtcblistingthe other tolisting options. – lukeflo Sep 04 '23 at 05:55