Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/api/latex_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def build_layout_comment_block(columns=4, font_size="9pt", margins="0.15in", spa
f"% @cheatsheet-layout spacing: {spacing} | change layout options up top to update spacing",
f"% @cheatsheet-layout margins: {margins} | change layout options up top to update margins",
f"% @cheatsheet-layout orientation: {orientation} | change layout options up top to update orientation",
"%",
"%"
]


Expand All @@ -148,12 +148,12 @@ def build_dynamic_header(columns=4, font_size="9pt", margins="0.15in", spacing="
spacing_values = get_spacing_values(spacing, font_size)
doc_class, doc_class_size = get_document_class(font_size)

# 1. Force the PDF driver to rotate by passing landscape and letterpaper to the document class
# Force the PDF driver to use letterpaper, add landscape if requested
doc_options = f"{doc_class_size},fleqn,letterpaper"
if orientation == "landscape":
doc_options += ",landscape"

# 2. Also pass them to the geometry package
# Also pass them to the geometry package
geometry_options = f"letterpaper,margin={margins}"
if orientation == "landscape":
geometry_options += ",landscape"
Expand Down
17 changes: 10 additions & 7 deletions backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def compile_latex(request):
font_size = cheatsheet.font_size
margins = cheatsheet.margins
spacing = cheatsheet.spacing
orientation = getattr(cheatsheet, "orientation", None) or "portrait"
content = cheatsheet.build_full_latex()

if not content:
Expand All @@ -380,15 +381,17 @@ def compile_latex(request):
content = normalize_latex_layout(content, columns, font_size, margins, spacing, orientation)

if normalize_only:
layout_response = {
"columns": columns,
"font_size": font_size,
"margins": margins,
"spacing": spacing,
"orientation": orientation,
}

return Response({
"tex_code": content,
"layout": {
"columns": columns,
"font_size": font_size,
"margins": margins,
"spacing": spacing,
"orientation": orientation,
},
"layout": layout_response,
})

with tempfile.TemporaryDirectory() as tempdir:
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/components/CreateCheatSheet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1273,8 +1273,6 @@ const CreateCheatSheet = ({ onSave, onReset, onRestoreSnapshot, initialData, isS
});
}, [columns, compileError, content, contentSource, fontSize, getSelectedFormulasList, margins, onSave, orientation, pdfBlob, spacing, title]);



const startResize = useCallback((panel) => (event) => {
event.preventDefault();

Expand Down Expand Up @@ -1763,4 +1761,4 @@ const CreateCheatSheet = ({ onSave, onReset, onRestoreSnapshot, initialData, isS
);
};

export default CreateCheatSheet;
export default CreateCheatSheet;
Loading