def read_tex_files(file_path:str, demacro:bool=False)->str:
    """Read all tex files in the latex source at `file_path`. If it is not a `tar.gz` file try to read it as text file.

    Args:
        file_path (str): Path to latex source
        demacro (bool, optional): Deprecated. Call external `de-macro` program. Defaults to False.

    Returns:
        str: All Latex files concatenated into one string.
    """    
    tex = ''
    try:
        with tempfile.TemporaryDirectory() as tempdir:
            try:
                tf = tarfile.open(file_path, 'r')
                tf.extractall(tempdir)
                tf.close()
                texfiles = [os.path.abspath(x) for x in glob.glob(os.path.join(tempdir, '**', '*.tex'), recursive=True)]
            except tarfile.ReadError as e:
                texfiles = [file_path]  # [os.path.join(tempdir, file_path+'.tex')]
            if demacro:
                ret = subprocess.run(['de-macro', *texfiles], cwd=tempdir, capture_output=True)
                if ret.returncode == 0:
                    texfiles = glob.glob(os.path.join(tempdir, '**', '*-clean.tex'), recursive=True)
            for texfile in texfiles:
                try:
                    ct = open(texfile, 'r', encoding='utf-8').read()
                    tex += ct
                except UnicodeDecodeError as e:
                    logging.debug(e)
                    pass
    except Exception as e:
        logging.debug('Could not read %s: %s' % (file_path, str(e)))
        raise e
    tex = pydemacro(tex)
    return tex
Read all tex files in the latex source at `file_path`. If it is not a `tar.gz` file try to read it as text file.

    Args:
        file_path (str): Path to latex source
        demacro (bool, optional): Deprecated. Call external `de-macro` program. Defaults to False.

    Returns:
        str: All Latex files concatenated into one string.
    
pix2tex/dataset/arxiv.py