<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_latex(circuit, settings=None):
 """ Translates a given pyquil Program to a TikZ picture in a Latex document. :param Program circuit: The circuit to be drawn, represented as a pyquil program. :param dict settings: An optional dictionary with settings for drawing the circuit. See `get_default_settings` in `latex_config` for more information about what settings should contain. :return: LaTeX document string which can be compiled. :rtype: string """

    if settings is None:
        settings = get_default_settings()
    text = header(settings)
    text += body(circuit, settings)
    text += footer()
    return text