def vector_title(flag, n, cmplx_part=None):
    """
    Creates a plot title for each left/right singular vector
    Returns a raw formatted string using LaTeX
    
    Parameters:
    flag: a string, either 'left' or 'right'
    n: a nonnegative integer
    dtype: data type (real or complex)
    """
    if flag == 'left':
        if cmplx_part == 'real':
            title = (
                '$\\mathrm{Re}\\{\\widehat{\\phi}_{%d}(\\mathbf{x}_r,\\nu)\\}$'
                 % n)
        elif cmplx_part == 'imag':
            title = (
                '$\\mathrm{Im}\\{\\widehat{\\phi}_{%d}(\\mathbf{x}_r,\\nu)\\}$'
                 % n)
        else:
            title = 'Left-Singular Vector $\\phi_{%d}(\\mathbf{x}_r,t)$' % n
    elif flag == 'right':
        if cmplx_part == 'real':
            title = (
                '$\\mathrm{Re}\\{\\widehat{\\psi}_{%d}(\\mathbf{x}_s,\\nu)\\}$'
                 % n)
        elif cmplx_part == 'imag':
            title = (
                '$\\mathrm{Im}\\{\\widehat{\\psi}_{%d}(\\mathbf{x}_s,\\nu)\\}$'
                 % n)
        else:
            title = 'Right-Singular Vector $\\psi_{%d}(\\mathbf{x}_s,t)$' % n
    return title
