Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize long expressions in LaTeX to prevent overflow #3910

Merged
merged 6 commits into from
Aug 19, 2024

Conversation

BilalM04
Copy link
Collaborator

@BilalM04 BilalM04 commented Aug 6, 2024

Contributes to #718

To save you the trouble of compiling, here is a precompiled example of SSP_SRS.pdf for your reference.

@smiths
Copy link
Collaborator

smiths commented Aug 6, 2024

The new pdfs are an improvement over the previous ones. I like this change to the generated stable files. @JacquesCarette or @balacij should review the Drasil code changes.

Copy link
Collaborator

@samm82 samm82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, likely non-blocking notes on another solid PR!

code/drasil-printers/lib/Language/Drasil/TeX/Preamble.hs Outdated Show resolved Hide resolved
code/drasil-printers/lib/Language/Drasil/TeX/Print.hs Outdated Show resolved Hide resolved
code/drasil-printers/lib/Language/Drasil/TeX/Print.hs Outdated Show resolved Hide resolved
code/drasil-printers/lib/Language/Drasil/TeX/Print.hs Outdated Show resolved Hide resolved
code/drasil-printers/lib/Language/Drasil/TeX/Print.hs Outdated Show resolved Hide resolved
Copy link
Owner

@JacquesCarette JacquesCarette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, but since you've opened this can of worms, may as well do it right!

code/stable/dblpend/SRS/PDF/DblPend_SRS.tex Outdated Show resolved Hide resolved
@@ -311,7 +322,7 @@ \subsubsection{Theoretical Models}

\\ \midrule
Equation & \begin{displaymath}
\symbf{a}\text{(}t\text{)}=\frac{\,d\symbf{v}\text{(}t\text{)}}{\,dt}
\resizeExpression{\symbf{a}\text{(}t\text{)}=\frac{\,d\symbf{v}\text{(}t\text{)}}{\,dt}}{0.8}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can predict that we'll likely want more processing of expressions in the future, so may as well abstract from that now. In other words, introduce a \formatExpr macro that wraps expressions, which would then just be resizeExpression{#1}{0.8}.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have both \resizeExpression{#1}{0.8} (printed by lo') and \resizeExpression{#1}{1.0} (printed by lo), does that mean we need to introduce two macros? For a more detailed explanation on why the differences in scale exist, please refer to #3910 (comment).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The macro should take a parameter that indicates whether to choose the in-definition or outside-definition case. While there should be booleans, it might still make sense to give them symbolic names, to make it clear what the meaning of the parameter is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, are you suggesting the following?

In addition to the existing variables/commands I created in this PR, which are as follows:

\def\inDefScale{0.8}
\def\outDefScale{1.0}

\newsavebox{\mybox}

\newcommand{\resizeExpression}[2]{
  \savebox{\mybox}{$#1$}
  \ifdim\wd\mybox>#2\linewidth
    \resizebox{#2\textwidth}{!}{\usebox{\mybox}}
  \else
    \usebox{\mybox}
  \fi
}

we want the following macro:

\newcommand{\InDef}{true}
\newcommand{\OutDef}{false}

\newcommand{\formatExpr}[2]{
  \if#2
    \resizeExpression{#1}{\inDefScale}
  \else
    \resizeExpression{#1}{\outDefScale}
  \fi
}

Thus, expressions will be printed as follows:

\formatExpr{...}{\outDef} % Outside definition table
\formatExpr{...}{\inDef} % Inside definition table

That’s how I understand it. Please let me know if I’ve misunderstood anything.

@JacquesCarette JacquesCarette merged commit 3c01497 into main Aug 19, 2024
5 checks passed
@JacquesCarette JacquesCarette deleted the texExpressions branch August 19, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants