环境设置如下:
\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;
你给的代码不能复现你的问题,建议做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编译
when close > lastday_close and close > nextday_cose then '波峰'
你把这个代码弄到跨页底下就会出现
@u69138
页面这样设置哈