复制 Eclipse 屏幕以显示 Java 代码

复制 Eclipse 屏幕以显示 Java 代码

嗨,有一种方法可以用关键字颜色复制 Eclipse 屏幕,如下所示的 Java 代码 在此处输入图片描述 我试过了,但是没用

\documentclass[a4paper, 11pt]{article} 
\usepackage{geometry}           
\geometry{top=3.0cm, bottom=2.5cm, left=2.5cm, right=2.5cm}
\usepackage[T1]{fontenc}        
\usepackage[utf8]{inputenc}     
\usepackage[italian]{babel}     
\usepackage{xcolor}

\usepackage{listings}
\renewcommand{\lstlistingname}{Box}% Listing -> Algorithm -> change name to listing enviroment
\renewcommand{\lstlistlistingname}{List of \lstlistingname s}% List of Listings -> List of Algorithms


\definecolor{pblue}{rgb}{0.13,0.13,1}
\definecolor{pgreen}{rgb}{0,0.5,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{pred}{rgb}{0.9,0,0}
\definecolor{pgrey}{rgb}{0.46,0.45,0.48}
\definecolor{apricot}{rgb}{0.98, 0.81, 0.69}


\lstset{language=Java,
    %uncomment the following line for tiny numbers beside the box
    %numbers=left, numberstyle=\tiny\color{codegray}, stepnumber=2, numbersep=10pt, 
    showspaces=false,
    showtabs=false,
    breaklines=true,
    showstringspaces=false,
    breakatwhitespace=true,
    commentstyle=\small \color{pgreen},
    keywordstyle=\small \color{pblue},
    stringstyle=\small \color{pred},
    basicstyle=\small \ttfamily,
    tabsize=2,
    moredelim=[il][\textcolor{pgrey}]{},
    moredelim=[is][\textcolor{pgrey}]{\%\%}
}

\begin{document}

\begin{lstlisting}[frame=single]
    TimeDiscretization timeDiscr2 =
        new TimeDiscretizationFromArray(new double[] {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0,
        1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0});
        
        BrownianMotionFromMersenneRandomNumbers brownianMotion2 = new BrownianMotionFromMersenneRandomNumbers(timeDiscr2, 2, numberOfPaths, 3231);
        MonteCarloMultiAssetBlackScholesModel bsmodelV2 = new MonteCarloMultiAssetBlackScholesModel
                (brownianMotion2,initialValues, riskFreeRate, volatilities, correlations);
        
        EuropeanOption call = new EuropeanOption(maturity,strike);
        RandomVariable valueOfCall = call.getValue(2.0, bsmodelV2);
        double priceCall = AnalyticFormulas.blackScholesOptionValue(initialValues[0], riskFreeRate, volatilities[0], maturity, strike);
\end{lstlisting}

\end{document}

相关内容