我有以下 tex 文件:
\documentclass[12pt,a4paper,twoside]{report}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{
language=Java,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
={\small\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true,
tabsize=3
}
\begin{document}
\begin{lstlisting}[caption={Third median in terms of $\theta$ and $\phi$},label={lst:f4}]
p, t= var('p t')
a=(-2*p*t^2-p^2*t)+(2*t*p-p^2)+t+1
b=(p*t^2+2*p^2*t)+(2*t*p-t^2)-p+1
c=(p*t^2-p^2*t)+(t^2+2*t*p+p^2)+t-p #3 sides (a,b,c) in terms of theta and phi
expand(2*a^2+2*b^2-c^2) #third median equation, m=1/2*sqrt(2*a^2+2*b^2-c^2)
9*p^4*t^2 + 18*p^3*t^3 + 9*p^2*t^4 + 6*p^4*t + 18*p^3*t^2 - 18*p^2*t^3 -
6*p*t^4 + p^4 - 22*p^3*t + 6*p^2*t^2 - 22*p*t^3 + t^4 + 2*p^3 - 6*p^2*t
+ 6*p*t^2 - 2*t^3 - 3*p^2 + 18*p*t - 3*t^2 - 4*p + 4*t + 4
\end{lstlisting}
\end{document}
我想将列表的字体改小一点,大概是这样的\tiny
。有人能指导我怎么做吗?
答案1
关键basicstyle
可能就是你想要的,即
\lstset{
basicstyle=\small\ttfamily,
...
}
\ttfamily
假设您要使用打字机字体。对于小于的字体,请根据需要将其\small
替换\small
为\footnotesize
或。\scriptsize
\tiny
您的 、(可能是您想要的) 和后来的key=value
中的键对中似乎缺少一些键,当然,我不知道那是用来做什么的。lstset
={\small\ttfamily}
basicstyle
=\color{blue}