add amsmath to needed packages

This commit is contained in:
Johanna Stuber 2021-03-05 16:56:23 +01:00
parent a442f5caf5
commit c2de56a29a
5 changed files with 14 additions and 25 deletions

View File

@ -25,7 +25,7 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver {
private static final String CLOSE_ICON_ID = "closeIcon";
private final TextField urlField;
private final TextField packageField;
private final TextArea packageArea;
private final TextArea latexArea;
private final H3 heading;
@ -34,11 +34,9 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver {
* to the String that is passed as corresponding parameter.
*
* @param url a permalink to share with other users
* @param latexPackages the needed LaTeX-packages to use the displayed mathematics
* in other LaTeX documents. Should be in the form \\usepackage&ltpackage&gt
* @param latexCode LaTeX code for users to copy into their own LaTeX document(s)
*/
public ShareDialog(String url, String latexPackages, String latexCode) {
public ShareDialog(String url, String latexCode) {
HorizontalLayout headingLayout = new HorizontalLayout();
headingLayout.setId(HEADING_LAYOUT_ID);
@ -55,17 +53,17 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver {
setId(SHARE_DIALOG_ID);
urlField = new TextField();
packageField = new TextField();
packageArea = new TextArea();
latexArea = new TextArea();
urlField.setValue(url);
urlField.setClassName(FIELD_CLASS);
packageField.setValue(latexPackages);
packageField.setClassName(FIELD_CLASS);
packageArea.setValue(getTranslation("share.neededPackages"));
packageArea.setClassName(FIELD_CLASS);
latexArea.setValue(latexCode);
latexArea.setClassName(FIELD_CLASS);
layout.add(urlField, packageField, latexArea);
layout.add(urlField, packageArea, latexArea);
add(headingLayout, layout);
}
@ -75,7 +73,7 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver {
public void localeChange(LocaleChangeEvent localeChangeEvent) {
heading.setText(getTranslation("share.heading"));
urlField.setLabel(getTranslation("share.url.label"));
packageField.setLabel(getTranslation("share.packages.label"));
packageArea.setLabel(getTranslation("share.packages.label"));
latexArea.setLabel(getTranslation("share.latex.label"));
}
}

View File

@ -82,7 +82,7 @@ public class TypeInferenceView extends VerticalLayout
@Override
public void shareButton() {
UI.getCurrent().getPage().executeJs("return decodeURI(window.location.href)").then(url ->
new ShareDialog(url.asString(), lc.getLatexPackages(), lc.getTree()).open()
new ShareDialog(url.asString(), lc.getTree()).open()
);
}

View File

@ -77,16 +77,6 @@ public class LatexCreator implements StepVisitor {
return constraintsCreator.getTreeNumbers();
}
/**
* Returns needed LaTeX packages
*
* @return the packages needed for the LaTeX-code from getTree() to work
*/
public String getLatexPackages() {
return BUSSPROOFS;
}
private String conclusionToLatex(Conclusion conclusion) {
String typeAssumptions = typeAssumptionsToLatex(conclusion.getTypeAssumptions());
String term = new LatexCreatorTerm(conclusion.getLambdaTerm()).getLatex();
@ -155,8 +145,7 @@ public class LatexCreator implements StepVisitor {
tree.insert(0, generateConclusion(varL, LABEL_VAR, UIC));
String typeAbstraction = generateTypeAbstraction(varL.getTypeAbsInPremise());
String instantiatedType = new LatexCreatorType(varL.getInstantiatedTypeAbs()).getLatex();
String premiseRight = DOLLAR_SIGN + typeAbstraction + INSTANTIATE_SIGN + instantiatedType
+ DOLLAR_SIGN + NEW_LINE;
String premiseRight = DOLLAR_SIGN + typeAbstraction + INSTANTIATE_SIGN + instantiatedType + DOLLAR_SIGN;
String premiseLeft = AXC + CURLY_LEFT + DOLLAR_SIGN + ALIGN_BEGIN
+ generateVarStepPremise(varL).replace(DOLLAR_SIGN, "")
+ SPACE + LATEX_NEW_LINE + SPACE // todo less replacement fixups

View File

@ -74,6 +74,4 @@ public final class LatexCreatorConstants {
protected static final String ALIGN_END = "\\end{aligned}";
protected static final String SPLIT_BEGIN = "\\begin{split}";
protected static final String SPLIT_END = "\\end{split}";
protected static final String BUSSPROOFS = "\\usepackage{bussproofs}";
}

View File

@ -79,4 +79,8 @@ root.varLetLatex=\
\
\\LeftLabel{\\textrm V{\\small AR}}\
\\BinaryInfC{$\\Gamma \\vdash \\texttt{x} : \\tau$}\
\\end{prooftree}
\\end{prooftree}
share.neededPackages=\
\\usepackage{bussproofs}\n\
\\usepackage{amsmath}