def build_position_tex(position):
    """
    Takes a position in the form of JSON schema and produces tex output for that
    env.
    """
    tex_env = "positionenv"
    end = ''
    comments = []
    skills = ''
    if "end" in position:
        end = position["end"]
    if "comments" in position:
        # If we find comments then assume a positionenv, i.e. build the comments
        # into a list
        tex_env = "positionlist"
        comments = position["comments"]
    if "skills" in position:
        skills = "; ".join(position["skills"])

    position_data = {
            "tex_env": tex_env,
            "title": position["title"],
            "start": position["start"],
            "end": end,
            "skills": skills
            }
    
    output = "\\begin{{{tex_env}}}{{{title}}}{{{start}}}{{{end}}}{{{skills}}}"
    output = output.format(**position_data)

    for comment in comments:
        output += ("\n    \\item " + comment)

    output += ("\n\\end{{{tex_env}}}\n\n".format(**position_data))
    
    return output