Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jamal Bouajjaj
Cantor
Commits
6c957327
Commit
6c957327
authored
Apr 08, 2021
by
Jamal Bouajjaj
Browse files
Fixed newline LaTeX equations. Replaced eqnarray with align
parent
f217abc8
Pipeline
#57046
passed with stage
in 26 minutes and 24 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/backends/sage/sageexpression.cpp
View file @
6c957327
...
...
@@ -189,8 +189,26 @@ void SageExpression::evalFinished()
const
bool
isLatex
=
m_outputCache
.
contains
(
QLatin1String
(
"
\\
newcommand{
\\
Bold}"
));
//Check if it's latex stuff
if
(
isLatex
)
//It's latex stuff so encapsulate it into an eqnarray environment
{
stripped
.
prepend
(
QLatin1String
(
"
\\
begin{eqnarray*}"
));
stripped
.
append
(
QLatin1String
(
"
\\
end{eqnarray*}"
));
int
bol_command_len
=
QLatin1String
(
"
\\
newcommand{
\\
Bold}[1]{
\\
mathbf{#1}}"
).
size
();
int
curr_index
=
stripped
.
indexOf
(
QLatin1String
(
"
\\
newcommand{
\\
Bold}[1]{
\\
mathbf{#1}}"
))
+
bol_command_len
;
// Add an & for the align environment
stripped
.
insert
(
curr_index
,
QLatin1String
(
"&"
));
// Strip away any additional "\\newcommand;{\\Bold}" so that it's compilable by LaTeX
if
(
stripped
.
count
(
QLatin1String
(
"
\\
newcommand{
\\
Bold}"
))
>
1
){
while
(
curr_index
!=
-
1
){
curr_index
=
stripped
.
indexOf
(
QLatin1String
(
"
\\
newcommand{
\\
Bold}[1]{
\\
mathbf{#1}}"
),
curr_index
);
stripped
.
remove
(
curr_index
,
bol_command_len
);
// Also add an & for left alignment
stripped
.
insert
(
curr_index
,
QLatin1String
(
"&"
));
}
}
// Replace new-line characters with \\ for LaTeX's newline intepretation
stripped
.
replace
(
QLatin1Char
(
'\n'
),
QLatin1String
(
"
\\\\
"
));
stripped
.
prepend
(
QLatin1String
(
"
\\
begin{align*}"
));
stripped
.
append
(
QLatin1String
(
"
\\
end{align*}"
));
// TODO: Remove for final merge
qDebug
()
<<
"NewCommand"
;
qDebug
()
<<
stripped
;
}
//strip html tags
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment