主页 M

latex中if与else条件代码,latex中大括号

2026-02-09 网页编程网 网页编程网

1.序

在latex写代码时,if条件的源代码

2.解决方案

If {condition1}     
    State a=1   
ElsIf {condition2}   
    State a=2       
Else   
    State a=3
EndIf

3.大括号解决方案

\documentclass{article}
\usepackage{amsmath}


\begin{document}
% 单侧大括号方程组
\begin{equation}
    f(x) = 
    \begin{cases}
        x^2 + 1 & \text{if } x \geq 0 \\
        -x^3 + 2x & \text{if } x < 0
    \end{cases}
\end{equation}


% 多行条件方程组
\begin{equation}
    \begin{cases}
        a_1x + b_1y = c_1 \\
        a_2x + b_2y = c_2 \\
        a_3x + b_3y = c_3
    \end{cases}
\end{equation}
\end{document}
阅读原文
阅读 398
123 显示电脑版