*주의 : 이 글은 overleaf를 기준으로 작성되었음
다음과 같이 style을 custom해서 설정한다.
\usepackage{listings}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{myred1}{rgb}{255, 0, 0}
% Define a custom style
\lstdefinestyle{myStyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2,
}
\begin{lstlisting}에서 캡션, 라벨, 그리고 사용 언어까지 지정할 수 있다.
아래 코드는 pseudo code처럼 작성하기는 했는데 matlab은 highlight가 좀 아쉽다.
% code block
\lstset{style=myStyle}
\begin{lstlisting}[caption=Problem2.m, label={lst:listing-matlab}, language=Matlab]
set reference Area(S), reference length(d), mass(m), moment of inertia(Iyy) according to assignment
% Find trim point
set the range of AoA, Mach, and Altitude for calculating trim point
for i = 1:(number of AoA)
for j = 1:(number of Mach)
for k = 1:(number of Altitude)
find density, velocity of sound using Environment function
Calculate Velocity and Dynamic pressure (V and Q)
find Coefficient using GetCoef function
Calculate trim state/output/input
end
end
end
plot the trim state/input/output when h=0m depending on AoA, Mach Number
% Linearized Model
Obtain G_az, G_q transfer function
Plot Step response when AoA=0, Mach=2.0, h=0m
Plot pole-zero location
\end{lstlisting}
컴파일 결과
'기타 > 논문작성 Writing' 카테고리의 다른 글
[LaTeX] 문서 Header 만들기 (0) | 2023.11.16 |
---|---|
[LaTeX] 기초(1) LaTeX가 뭔가요 (0) | 2023.09.27 |
[논문작성] Word에 수식번호 추가하기 (0) | 2023.09.13 |
[LaTeX] LaTeX Error: Command \openbox already defined. (0) | 2023.06.16 |
[논문작성] physics와 siunitx package 활용하기 (0) | 2023.06.06 |