
    IR-e
                     d    d Z ddlZddlmZmZ  G d dej                  Z G d de          ZdS )	z"
Handles the "LaTeX" unit format.
    N   )consoleutilsc                        e Zd ZdZdZdZdZed             Zed             Z	ed             Z
edd            Zed	d
 fd
            Zed fd	            Z xZS )Latexz
    Output LaTeX to display the unit based on IAU style guidelines.

    Attempts to follow the `IAU Style Manual
    <https://www.iau.org/static/publications/stylemanual1989.pdf>`_.
    z\,z \times c                 r    |                     d          }||j        k    r|                    dd          S |S )Nlatex_z\_)get_format_namenamereplace)clsunitr   s      :lib/python3.11/site-packages/astropy/units/format/latex.py_get_unit_namezLatex._get_unit_name   s?     ##G,,49 <<U+++K    c                 V    |                     dd                               dd          S )Nnanz	{\rm NaN}infz\infty)r   )r   ms     r   _format_mantissazLatex._format_mantissa$   s&    yy--55eYGGGr   c                     d| dS )Nz^{} )r   numbers     r   _format_superscriptzLatex._format_superscript(   s    Vr   r   c                     |                      |          }|dk    rLt          j        d|          r|j        d         }||                     t          j        |                    z  }|S )Nr   z.*\^{[^}]*}$r   )r   rematchshort_namesr   r   format_power)r   r   powerr   s       r   _format_unit_powerzLatex._format_unit_power,   si    !!$''A::
 x.. +'*C++E,>u,E,EFFFDr   	multilinefractionc                p    |dk    r%t                                          ||||          S | d| d| dS )Nr$   r%   z\frac{z}{r   )super_format_fraction)r   scale	numeratordenominatorr&   	__class__s        r   r)   zLatex._format_fraction9   sY    {""77++y+ ,    ????????r   c                 V    t                                          ||          }d| dS )Nr%   z	$\mathrm{z}$r(   	to_string)r   r   r&   sr-   s       r   r0   zLatex.to_stringB   s0    GGdX66#Q####r   )r   )r$   )__name__
__module____qualname____doc___space_scale_unit_separator_timesclassmethodr   r   r   r#   r)   r0   __classcell__r-   s   @r   r   r      s         F!F	 	 [	 H H [H     [  
 
 
 [
 IT @ @ @ @ @ @ [@ $ $ $ $ $ [$ $ $ $ $r   r   c                   8     e Zd ZdZdZed fd	            Z xZS )LatexInlinea2  
    Output LaTeX to display the unit based on IAU style guidelines with negative
    powers.

    Attempts to follow the `IAU Style Manual
    <https://www.iau.org/static/publications/stylemanual1989.pdf>`_ and the
    `ApJ and AJ style guide
    <https://journals.aas.org/manuscript-preparation/>`_.
    latex_inlineFc                 J    t                                          ||          S )Nr%   r/   )r   r   r&   r-   s      r   r0   zLatexInline.to_stringU   s     ww   999r   )F)r2   r3   r4   r5   r   r9   r0   r:   r;   s   @r   r=   r=   H   sX          D: : : : : [: : : : :r   r=   )r5   r    r   r   Consoler   r=   r   r   r   <module>rB      s     
			        9$ 9$ 9$ 9$ 9$GO 9$ 9$ 9$x: : : : :% : : : : :r   