Commit 6c957327 authored by Jamal Bouajjaj's avatar 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
......@@ -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
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("\\\\"));
// TODO: Remove for final merge
//strip html tags
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment