10 minted代码跨行分割后无背景颜色了

发布于 2024-07-16 12:49:58

环境设置如下:

\usepackage{minted}
% 缩短代码前后的距离
\BeforeBeginEnvironment{minted@colorbg}{\vspace{-0.3cm}}
\AfterEndEnvironment{minted@colorbg}{\vspace{-1cm}}

\definecolor{bg}{rgb}{0.95,0.95,0.95}
% 设置全局参数
\setminted[sql]{
    xleftmargin=1.4mm,
    xrightmargin=1.4mm,
    bgcolor=bg_2,
    breaklines,
    %breakanywhere=true,
    linenos=false,
    numbersep=10pt,
    gobble=0,
    %baselinestretch=1,
    tabsize=4,
    %frame=none,
    fontfamily=mycode,
    fontsize=\small,
    framesep=2mm,
    breaksymbolleft={},
    breakindent={15pt}
}
\inputminted{sql}{Code/sql/11.sql}
select
    ts_code,
    trade_date,
    close,
    case 
        when close > lastday_close and close > nextday_cose then '波峰'
        when close < lastday_close and close < nextday_cose then '波谷'
        else '其他' end as point_type
from 
(
    select
        ts_code,
        trade_date,
        close,
        lag(close, 1) over (partition by ts_code order by trade_date) as lastday_close,
        lead(close, 1) over (partition by ts_code order by trade_date) as nextday_cose
    from t_stock_test
) t;

1.png

查看更多

关注者
0
被浏览
472
1 个回答
1210
1210 2024-07-17
道阻且长,行则将至,行而不辍,未来可期

你给的代码不能复现你的问题,建议做MWE.

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[width=210mm, height=297mm, left=2cm, right=2cm, top=2cm, bottom=2cm]{geometry}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{xcolor}
\usepackage{minted}
\usepackage{ctex}
\usepackage{minted}
\usepackage{lipsum}
% 缩短代码前后的距离
\BeforeBeginEnvironment{minted@colorbg}{\vspace{-0.3cm}}
\AfterEndEnvironment{minted@colorbg}{\vspace{-1cm}}

\definecolor{bg}{rgb}{0.95,0.95,0.95}
% 设置全局参数
\setminted[sql]{
    xleftmargin=1.4mm,
    xrightmargin=1.4mm,
    bgcolor=bg,
    breaklines,
    %breakanywhere=true,
    linenos=false,
    numbersep=10pt,
    gobble=0,
    %baselinestretch=1,
    tabsize=4,
    %frame=none,
    fontfamily=mycode,
    fontsize=\small,
    framesep=2mm,
    breaksymbolleft={},
    breakindent={15pt}
}
\begin{document}
\lipsum[1-5]
\begin{minted}{sql}
select
    ts_code,
    trade_date,
    close,
    case 
        when close > lastday_close and close > nextday_cose then '波峰'
        when close < lastday_close and close < nextday_cose then '波谷'
        else '其他' end as point_type
from 
(
    select
        ts_code,
        trade_date,
        close,
        lag(close, 1) over (partition by ts_code order by trade_date) as lastday_close,
        lead(close, 1) over (partition by ts_code order by trade_date) as nextday_cose
    from t_stock_test
) t;
\end{minted}
\end{document}

本地环境: win11 23H2 + TeX Live 2024 + XeLaTeX编译
image.png

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览