Doxygen
Loading...
Searching...
No Matches
latexgen.cpp File Reference
#include <cstdlib>
#include "latexgen.h"
#include "config.h"
#include "message.h"
#include "doxygen.h"
#include "util.h"
#include "stringutil.h"
#include "diagram.h"
#include "language.h"
#include "version.h"
#include "dot.h"
#include "dotcallgraph.h"
#include "dotclassgraph.h"
#include "dotdirdeps.h"
#include "dotgroupcollaboration.h"
#include "dotincldepgraph.h"
#include "pagedef.h"
#include "docparser.h"
#include "docnode.h"
#include "latexdocvisitor.h"
#include "dirdef.h"
#include "cite.h"
#include "groupdef.h"
#include "classlist.h"
#include "namespacedef.h"
#include "filename.h"
#include "resourcemgr.h"
#include "portable.h"
#include "fileinfo.h"
#include "utf8.h"
#include "datetime.h"
#include "outputlist.h"
#include "moduledef.h"
Include dependency graph for latexgen.cpp:

Go to the source code of this file.

Macros

#define COPYCHAR()

Functions

static DString substituteLatexKeywords (const DString &file, const DString &str, const DString &title)
static void writeLatexMakefile ()
static void writeMakeBat ()
static void writeDefaultStyleSheet (TextStream &t)
static DString extraLatexStyleSheet ()
static DString makeIndex ()
static DString latex_batchmode ()
static DString objectLinkToString (const DString &ref, const DString &f, const DString &anchor, const DString &text, bool insideTabbing, bool disableLinks)
static void processEntity (TextStream &t, bool pdfHyperlinks, const char *strForm, const char *strRepl)
void writeExtraLatexPackages (TextStream &t)
void writeLatexSpecialFormulaChars (TextStream &t)
void filterLatexString (TextStream &t, const DString &str, bool insideTabbing, bool insidePre, bool insideItem, bool insideTable, bool keepSpaces, const bool retainNewline)
DString convertToLaTeX (const DString &s, bool insideTabbing, bool keepSpaces)
DString latexEscapeLabelName (const DString &s)
DString latexEscapeIndexChars (const DString &s)
DString latexEscapePDFString (const DString &s)
DString latexFilterURL (const DString &s)
void latexWriteIndexItem (TextStream &m_t, const DString &s1, const DString &s2)

Variables

static DString g_header
static DString g_header_file
static DString g_footer
static DString g_footer_file
static const SelectionMarkerInfo latexMarkerInfo = { '%', "%%BEGIN ",8 ,"%%END ",6, "",0 }

Macro Definition Documentation

◆ COPYCHAR

#define COPYCHAR ( )
Value:
do { \
int bytes = getUTF8CharNumBytes(c); \
if (lresult < (i + bytes + 1)) \
{ \
lresult += 512; \
result = static_cast<char *>(realloc(result, lresult)); \
} \
for (int j=0; j<bytes && *p; j++) \
{ \
result[i++]=*p++; \
} \
m_col++; \
} while(0)
uint8_t getUTF8CharNumBytes(char c)
Returns the number of bytes making up a single UTF8 character given the first byte in the sequence.
Definition utf8.cpp:23

Referenced by LatexCodeGenerator::codify().

Function Documentation

◆ convertToLaTeX()

DString convertToLaTeX ( const DString & s,
bool insideTabbing,
bool keepSpaces )

Definition at line 2509 of file latexgen.cpp.

2510{
2511 TextStream t;
2512 filterLatexString(t,s,insideTabbing,false,false,false,keepSpaces);
2513 return t.str();
2514}
Text streaming class that buffers data.
Definition textstream.h:36
std::string str() const
Return the contents of the buffer as a std::string object.
Definition textstream.h:232
void filterLatexString(TextStream &t, const DString &str, bool insideTabbing, bool insidePre, bool insideItem, bool insideTable, bool keepSpaces, const bool retainNewline)

References convertToLaTeX(), filterLatexString(), and TextStream::str().

Referenced by convertToLaTeX(), LatexGenerator::endIndexSection(), objectLinkToString(), LatexGenerator::startIndexSection(), substituteLatexKeywords(), and LatexGenerator::writeInheritedSectionTitle().

◆ extraLatexStyleSheet()

DString extraLatexStyleSheet ( )
static

Definition at line 739 of file latexgen.cpp.

740{
741 DString result;
742 StringVector extraLatexStyles = Config_getList(LATEX_EXTRA_STYLESHEET);
743 for (const auto &fileName : extraLatexStyles)
744 {
745 if (!fileName.empty())
746 {
747 FileInfo fi(fileName);
748 if (fi.exists())
749 {
750 result += "\\usepackage{";
751 DString fn = fi.fileName();
753 {
754 // strip the extension, it will be added by the usepackage in the tex conversion process
756 }
757 else
758 {
759 result += fn;
760 }
761 result += "}\n";
762 }
763 }
764 }
765 return result;
766}
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:89
Minimal replacement for QFileInfo.
Definition fileinfo.h:23
#define Config_getList(name)
Definition config.h:38
std::vector< std::string > StringVector
Definition containers.h:33
#define LATEX_STYLE_EXTENSION
Definition latexgen.h:22
bool checkExtension(const DString &fName, const DString &ext)
Definition util.cpp:4255
DString stripExtensionGeneral(const DString &fName, const DString &ext)
Definition util.cpp:4274

References checkExtension(), Config_getList, FileInfo::exists(), extraLatexStyleSheet(), FileInfo::fileName(), LATEX_STYLE_EXTENSION, and stripExtensionGeneral().

Referenced by extraLatexStyleSheet(), and substituteLatexKeywords().

◆ filterLatexString()

void filterLatexString ( TextStream & t,
const DString & str,
bool insideTabbing,
bool insidePre,
bool insideItem,
bool insideTable,
bool keepSpaces,
const bool retainNewline )

Definition at line 2362 of file latexgen.cpp.

2364{
2365 if (str.empty()) return;
2366 bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
2367 //printf("filterLatexString(%s) insideTabbing=%d\n",qPrint(str),insideTabbing);
2368 const char *p = str.data();
2369 unsigned char pc='\0';
2370
2371 while (*p)
2372 {
2373 unsigned char c=static_cast<unsigned char>(*p++);
2374
2375 if (insidePre)
2376 {
2377 switch(c)
2378 {
2379 case 0xef: // handle U+FFFD i.e. "Replacement character" caused by octal: 357 277 275 / hexadecimal 0xef 0xbf 0xbd
2380 // the LaTeX command \ucr has been defined in doxygen.sty
2381 if (static_cast<unsigned char>(*(p)) == 0xbf && static_cast<unsigned char>(*(p+1)) == 0xbd)
2382 {
2383 t << "{\\ucr}";
2384 p += 2;
2385 }
2386 else
2387 t << static_cast<char>(c);
2388 break;
2389 case '\\': t << "\\(\\backslash\\)"; break;
2390 case '{': t << "\\{"; break;
2391 case '}': t << "\\}"; break;
2392 case '_': t << "\\_"; break;
2393 case '&': t << "\\&"; break;
2394 case '%': t << "\\%"; break;
2395 case '#': t << "\\#"; break;
2396 case '$': t << "\\$"; break;
2397 case '"': t << "\"{}"; break;
2398 case '-': t << "-\\/"; break;
2399 case '^': insideTable ? t << "\\string^" : t << static_cast<char>(c); break;
2400 case '~': t << "\\string~"; break;
2401 case '\n': if (retainNewline) t << "\\newline"; else t << ' ';
2402 break;
2403 case ' ': if (keepSpaces) t << "~"; else t << ' ';
2404 break;
2405 default:
2406 if (c<32) t << ' '; // non printable control character
2407 else t << static_cast<char>(c);
2408 break;
2409 }
2410 }
2411 else
2412 {
2413 switch(c)
2414 {
2415 case 0xef: // handle U+FFFD i.e. "Replacement character" caused by octal: 357 277 275 / hexadecimal 0xef 0xbf 0xbd
2416 // the LaTeX command \ucr has been defined in doxygen.sty
2417 if (static_cast<unsigned char>(*(p)) == 0xbf && static_cast<unsigned char>(*(p+1)) == 0xbd)
2418 {
2419 t << "{\\ucr}";
2420 p += 2;
2421 }
2422 else
2423 t << static_cast<char>(c);
2424 break;
2425 case '#': t << "\\+\\#"; break;
2426 case '$': t << "\\$"; break;
2427 case '%': t << "\\%"; break;
2428 case '^': processEntity(t,pdfHyperlinks,"$^\\wedge$","\\string^"); break;
2429 case '&': {
2430 // possibility to have a special symbol
2432 t,
2433 p-1,
2434 [](HtmlEntityMapper::SymType symType) { return HtmlEntityMapper::instance().latex(symType); },
2435 "\\&");
2436 }
2437 break;
2438 case '*': processEntity(t,pdfHyperlinks,"$\\ast$","*"); break;
2439 case '_': if (!insideTabbing && *p) t << "\\+";
2440 t << "\\_";
2441 if (!insideTabbing && *p) t << "\\+";
2442 break;
2443 case '{': t << "\\{"; break;
2444 case '}': t << "\\}"; break;
2445 case '<': t << "$<$"; break;
2446 case '>': t << "$>$"; break;
2447 case '|': processEntity(t,pdfHyperlinks,"$\\vert$","|"); break;
2448 case '~': processEntity(t,pdfHyperlinks,"$\\sim$","\\string~"); break;
2449 case '[': if (Config_getBool(PDF_HYPERLINKS) || insideItem)
2450 t << "\\+[";
2451 else
2452 t << "[";
2453 break;
2454 case ']': if (pc=='[') t << "$\\,$";
2455 if ((Config_getBool(PDF_HYPERLINKS) || insideItem) && *p)
2456 t << "]\\+";
2457 else
2458 t << "]";
2459 break;
2460 case '-': t << "-\\/";
2461 break;
2462 case '\\': t << "\\textbackslash{}";
2463 break;
2464 case '"': t << "\"{}";
2465 break;
2466 case '`': t << "\\`{}";
2467 break;
2468 case '\'': t << "\\textquotesingle{}";
2469 break;
2470 case '\n': if (retainNewline)
2471 {
2472 t << "\\newline";
2473 if (insideTable) t << " ";
2474 }
2475 else
2476 {
2477 t << ' ';
2478 }
2479 break;
2480 case ' ': if (keepSpaces) { if (insideTabbing) t << "\\>"; else t << '~'; } else t << ' ';
2481 break;
2482
2483 default:
2484 //if (!insideTabbing && forceBreaks && c!=' ' && *p!=' ')
2485 if (!insideTabbing &&
2486 ((c>='A' && c<='Z' && pc!=' ' && !(pc>='A' && pc <= 'Z') && pc!='\0' && *p) || (pc=='.' && isId(c)))
2487 )
2488 {
2489 t << "\\+";
2490 }
2491 if (c<32)
2492 {
2493 t << ' '; // non-printable control character
2494 }
2495 else
2496 {
2497 t << static_cast<char>(c);
2498 }
2499 if (!insideTabbing && *p && ((c==':' && *p!=':') || c=='/'))
2500 {
2501 t << "\\+";
2502 }
2503 }
2504 }
2505 pc = c;
2506 }
2507}
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:153
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:162
const char * latex(SymType symb) const
Access routine to the LaTeX code of the HTML entity.
const char * writeHtmlEntity(T &result, const char *s, HtmlEntityMapperFunc &&mapper, const char *fallback)
Definition htmlentity.h:127
static HtmlEntityMapper & instance()
Returns the one and only instance of the HTML entity mapper.
#define Config_getBool(name)
Definition config.h:33
bool insideTable(const DocNodeVariant *n)
bool isId(int c)
Returns true if c is a valid character for an identifier.
Definition dstring.h:884
static void processEntity(TextStream &t, bool pdfHyperlinks, const char *strForm, const char *strRepl)

References Config_getBool, DString::data(), DString::empty(), filterLatexString(), insideTable(), HtmlEntityMapper::instance(), isId(), HtmlEntityMapper::latex(), processEntity(), and HtmlEntityMapper::writeHtmlEntity().

Referenced by LatexCodeGenerator::codify(), convertToLaTeX(), LatexGenerator::docify(), LatexDocVisitor::filter(), filterLatexString(), latexEscapeIndexChars(), latexEscapeLabelName(), and substituteLatexKeywords().

◆ latex_batchmode()

DString latex_batchmode ( )
static

Definition at line 786 of file latexgen.cpp.

787{
788 switch (Config_getEnum(LATEX_BATCHMODE))
789 {
790 case LATEX_BATCHMODE_t::NO: return "";
791 case LATEX_BATCHMODE_t::YES: return "\\batchmode";
792 case LATEX_BATCHMODE_t::BATCH: return "\\batchmode";
793 case LATEX_BATCHMODE_t::NON_STOP: return "\\nonstopmode";
794 case LATEX_BATCHMODE_t::SCROLL: return "\\scrollmode";
795 case LATEX_BATCHMODE_t::ERROR_STOP: return "\\errorstopmode";
796 }
797 return "";
798}
#define Config_getEnum(name)
Definition config.h:35

References Config_getEnum, and latex_batchmode().

Referenced by latex_batchmode(), and substituteLatexKeywords().

◆ latexEscapeIndexChars()

DString latexEscapeIndexChars ( const DString & s)

Definition at line 2561 of file latexgen.cpp.

2562{
2563 //printf("latexEscapeIndexChars(%s)\n",qPrint(s));
2564 if (s.empty()) return s;
2566 TextStream t;
2567 const char *p=s.data();
2568 char c = 0;
2569 while ((c=*p++))
2570 {
2571 switch (c)
2572 {
2573 case '!': t << "\"!"; break;
2574 case '"': t << "\"\""; break;
2575 case '@': t << "\"@"; break;
2576 case '|': t << "\\texttt{\"|}"; break;
2577 case '[': t << "["; break;
2578 case ']': t << "]"; break;
2579 case '{': t << "\\lcurly{}"; break;
2580 case '}': t << "\\rcurly{}"; break;
2581 // NOTE: adding a case here, means adding it to while below as well!
2582 default:
2583 {
2584 int i=0;
2585 // collect as long string as possible, before handing it to docify
2586 tmp[i++]=c;
2587 while ((c=*p) && c!='"' && c!='@' && c!='[' && c!=']' && c!='!' && c!='{' && c!='}' && c!='|')
2588 {
2589 tmp[i++]=c;
2590 p++;
2591 }
2592 tmp[i]=0;
2593 filterLatexString(t,tmp,
2594 true, // insideTabbing
2595 false, // insidePre
2596 false, // insideItem
2597 false, // insideTable
2598 false // keepSpaces
2599 );
2600 }
2601 break;
2602 }
2603 }
2604 return t.str();
2605}
@ ExplicitSize
Definition dstring.h:136
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:156

References DString::data(), DString::empty(), DString::ExplicitSize, filterLatexString(), latexEscapeIndexChars(), DString::length(), and TextStream::str().

Referenced by latexEscapeIndexChars(), latexWriteIndexItem(), and LatexGenerator::startMemberDoc().

◆ latexEscapeLabelName()

DString latexEscapeLabelName ( const DString & s)

Definition at line 2516 of file latexgen.cpp.

2517{
2518 //printf("latexEscapeLabelName(%s)\n",qPrint(s));
2519 if (s.empty()) return s;
2521 TextStream t;
2522 const char *p=s.data();
2523 char c = 0;
2524 while ((c=*p++))
2525 {
2526 switch (c)
2527 {
2528 case '|': t << "\\texttt{\"|}"; break;
2529 case '!': t << "\"!"; break;
2530 case '@': t << "\"@"; break;
2531 case '%': t << "\\%"; break;
2532 case '{': t << "\\lcurly{}"; break;
2533 case '}': t << "\\rcurly{}"; break;
2534 case '~': t << "````~"; break; // to get it a bit better in index together with other special characters
2535 // NOTE: adding a case here, means adding it to while below as well!
2536 default:
2537 {
2538 int i=0;
2539 // collect as long string as possible, before handing it to docify
2540 tmp[i++]=c;
2541 while ((c=*p) && c!='@' && c!='[' && c!=']' && c!='!' && c!='{' && c!='}' && c!='|')
2542 {
2543 tmp[i++]=c;
2544 p++;
2545 }
2546 tmp[i]=0;
2547 filterLatexString(t,tmp,
2548 true, // insideTabbing
2549 false, // insidePre
2550 false, // insideItem
2551 false, // insideTable
2552 false // keepSpaces
2553 );
2554 }
2555 break;
2556 }
2557 }
2558 return t.str();
2559}

References DString::data(), DString::empty(), DString::ExplicitSize, filterLatexString(), latexEscapeLabelName(), DString::length(), and TextStream::str().

Referenced by latexEscapeLabelName(), and latexWriteIndexItem().

◆ latexEscapePDFString()

DString latexEscapePDFString ( const DString & s)

Definition at line 2607 of file latexgen.cpp.

2608{
2609 if (s.empty()) return s;
2610 TextStream t;
2611 const char *p=s.data();
2612 char c = 0;
2613 while ((c=*p++))
2614 {
2615 switch (c)
2616 {
2617 case '\\': t << "\\textbackslash{}"; break;
2618 case '{': t << "\\{"; break;
2619 case '}': t << "\\}"; break;
2620 case '_': t << "\\_"; break;
2621 case '%': t << "\\%"; break;
2622 case '&': t << "\\&"; break;
2623 case '#': t << "\\#"; break;
2624 case '$': t << "\\$"; break;
2625 case '^': t << "\\string^"; break;
2626 case '~': t << "\\string~"; break;
2627 default:
2628 t << c;
2629 break;
2630 }
2631 }
2632 return t.str();
2633}

References DString::data(), DString::empty(), latexEscapePDFString(), and TextStream::str().

Referenced by latexEscapePDFString(), and LatexGenerator::startMemberDoc().

◆ latexFilterURL()

DString latexFilterURL ( const DString & s)

Definition at line 2635 of file latexgen.cpp.

2636{
2637 constexpr auto hex = "0123456789ABCDEF";
2638 if (s.empty()) return s;
2639 TextStream t;
2640 const char *p=s.data();
2641 char c = 0;
2642 while ((c=*p++))
2643 {
2644 switch (c)
2645 {
2646 case '#': t << "\\#"; break;
2647 case '%': t << "\\%"; break;
2648 case '\\': t << "\\\\"; break;
2649 case '\n': break; // ignore
2650 default:
2651 if (c<0)
2652 {
2653 unsigned char id = static_cast<unsigned char>(c);
2654 t << "\\%" << hex[id>>4] << hex[id&0xF];
2655 }
2656 else
2657 {
2658 t << c;
2659 }
2660 break;
2661 }
2662 }
2663 return t.str();
2664}

References DString::data(), DString::empty(), latexFilterURL(), and TextStream::str().

Referenced by latexFilterURL(), LatexDocVisitor::operator()(), and LatexDocVisitor::operator()().

◆ latexWriteIndexItem()

void latexWriteIndexItem ( TextStream & m_t,
const DString & s1,
const DString & s2 )

Definition at line 2666 of file latexgen.cpp.

2667{
2668 if (!s1.empty())
2669 {
2670 m_t << "\\index{";
2671 m_t << latexEscapeLabelName(s1);
2672 m_t << "@{";
2673 m_t << latexEscapeIndexChars(s1);
2674 m_t << "}";
2675 if (!s2.empty())
2676 {
2677 m_t << "!";
2678 m_t << latexEscapeLabelName(s2);
2679 m_t << "@{";
2680 m_t << latexEscapeIndexChars(s2);
2681 m_t << "}";
2682 }
2683 m_t << "}\n";
2684 }
2685}
DString latexEscapeIndexChars(const DString &s)
DString latexEscapeLabelName(const DString &s)

References DString::empty(), latexEscapeIndexChars(), latexEscapeLabelName(), and latexWriteIndexItem().

Referenced by LatexGenerator::addIndexItem(), LatexGenerator::endTitleHead(), latexWriteIndexItem(), LatexDocVisitor::operator()(), and LatexGenerator::startMemberDoc().

◆ makeIndex()

DString makeIndex ( )
static

Definition at line 768 of file latexgen.cpp.

769{
770 DString result;
771 DString latex_mkidx_command = Config_getString(LATEX_MAKEINDEX_CMD);
772 if (!latex_mkidx_command.empty())
773 {
774 if (latex_mkidx_command[0] == '\\')
775 result += latex_mkidx_command;
776 else
777 result += "\\"+latex_mkidx_command;
778 }
779 else
780 {
781 result += "\\makeindex";
782 }
783 return result;
784}
#define Config_getString(name)
Definition config.h:32

References Config_getString, DString::empty(), and makeIndex().

Referenced by makeIndex(), and substituteLatexKeywords().

◆ objectLinkToString()

DString objectLinkToString ( const DString & ref,
const DString & f,
const DString & anchor,
const DString & text,
bool insideTabbing,
bool disableLinks )
static

Definition at line 1413 of file latexgen.cpp.

1416{
1417 bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
1418 DString result;
1419 if (!disableLinks && ref.empty() && pdfHyperlinks)
1420 {
1421 result += "\\doxymbox{\\hyperlink{";
1422 if (!f.empty()) result += stripPath(f);
1423 if (!f.empty() && !anchor.empty()) result += "_";
1424 if (!anchor.empty()) result += anchor;
1425 result += "}{";
1426 result += convertToLaTeX(text,insideTabbing);
1427 result += "}}";
1428 }
1429 else
1430 {
1431 result += "\\textbf{ ";
1432 result += convertToLaTeX(text,insideTabbing);
1433 result += "}";
1434 }
1435 return result;
1436}
DString convertToLaTeX(const DString &s, bool insideTabbing, bool keepSpaces)
DString stripPath(const DString &s)
Definition util.cpp:4289

References Config_getBool, convertToLaTeX(), DString::empty(), objectLinkToString(), and stripPath().

Referenced by objectLinkToString(), LatexGenerator::writeInheritedSectionTitle(), and LatexGenerator::writeObjectLink().

◆ processEntity()

void processEntity ( TextStream & t,
bool pdfHyperlinks,
const char * strForm,
const char * strRepl )
static

Definition at line 1438 of file latexgen.cpp.

1439{
1440 if (pdfHyperlinks)
1441 {
1442 t << "\\texorpdfstring{";
1443 }
1444 t << strForm;
1445 if (pdfHyperlinks)
1446 {
1447 t << "}{" << strRepl << "}";
1448 }
1449}

References processEntity().

Referenced by filterLatexString(), and processEntity().

◆ substituteLatexKeywords()

DString substituteLatexKeywords ( const DString & file,
const DString & str,
const DString & title )
static

Definition at line 800 of file latexgen.cpp.

803{
804 bool compactLatex = Config_getBool(COMPACT_LATEX);
805 bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
806 bool usePdfLatex = Config_getBool(USE_PDFLATEX);
807 DString paperType = Config_getEnumAsString(PAPER_TYPE);
808
809 DString style = Config_getString(LATEX_BIB_STYLE);
810 if (style.empty())
811 {
812 style="plainnat";
813 }
814
815 TextStream tg;
816 DString generatedBy;
817 auto timeStamp = Config_getEnum(TIMESTAMP);
818 switch (timeStamp)
819 {
820 case TIMESTAMP_t::YES:
821 case TIMESTAMP_t::DATETIME:
823 Config_getString(PROJECT_NAME));
824 break;
825 case TIMESTAMP_t::DATE:
827 Config_getString(PROJECT_NAME));
828 break;
829 case TIMESTAMP_t::NO:
830 generatedBy = theTranslator->trGeneratedBy();
831 break;
832 }
833 filterLatexString(tg, generatedBy,
834 false, // insideTabbing
835 false, // insidePre
836 false, // insideItem
837 false, // insideTable
838 false // keepSpaces
839 );
840 generatedBy = tg.str();
841
842 DString latexFontenc = theTranslator->latexFontenc();
843
844 DString latexEmojiDirectory = Config_getString(LATEX_EMOJI_DIRECTORY);
845 if (latexEmojiDirectory.empty()) latexEmojiDirectory = ".";
846 latexEmojiDirectory = substitute(latexEmojiDirectory,"\\","/");
847
848 TextStream tg1;
850 DString extraLatexPackages = tg1.str();
851
852 TextStream tg2;
854 DString latexSpecialFormulaChars = tg2.str();
855
856 DString formulaMacrofile = Config_getString(FORMULA_MACROFILE);
857 DString stripMacroFile;
858 if (!formulaMacrofile.empty())
859 {
860 FileInfo fi(formulaMacrofile.str());
861 formulaMacrofile=fi.absFilePath();
862 stripMacroFile = fi.fileName();
863 copyFile(formulaMacrofile,Config_getString(LATEX_OUTPUT) + "/" + stripMacroFile);
864 }
865
866 DString projectNumber = Config_getString(PROJECT_NUMBER);
867 DString projName = convertToLaTeX(Config_getString(PROJECT_NAME), false);
868 DString projBrief = convertToLaTeX(Config_getString(PROJECT_BRIEF),false);
869
870 // first substitute generic keywords then the LaTeX only keywords
871 DString result = substituteKeywords(file,str,
872 {
873 // keyword value getter
874 { "$title", [&]() { return !title.empty() ? title : projName; } },
875 { "$doxygenversion", [&]() { return getDoxygenVersion(); } },
876 { "$projectname", [&]() { return projName; } },
877 { "$projectnumber", [&]() { return convertToLaTeX(projectNumber,false); } },
878 { "$projectbrief", [&]() { return projBrief; } },
879 { "$projectlogo", [&]() { return stripPath(projectLogoFile()); } },
880 { "$logosize", [&]() { return projectLogoSize(); } },
881 { "$projecticon", [&]() { return stripPath(Config_getString(PROJECT_ICON)); } },
882 { "$langISO", [&]() { return theTranslator->trISOLang(); } },
883 { "$showdate", [&](const DString &fmt) { return showDate(fmt); } },
884
885 // keyword value getter
886 { "$datetime", [&]() { return dateToString(DateTimeType::DateTime); } },
887 { "$date", [&]() { return dateToString(DateTimeType::Date); } },
888 { "$time", [&]() { return dateToString(DateTimeType::Time); } },
889 { "$year", [&]() { return yearToString(); } },
890 { "$latexdocumentpre", [&]() { return theTranslator->latexDocumentPre(); } },
891 { "$latexdocumentpost", [&]() { return theTranslator->latexDocumentPost(); } },
892 { "$generatedby", [&]() { return generatedBy; } },
893 { "$latexbibstyle", [&]() { return style; } },
894 { "$latexcitereference", [&]() { return theTranslator->trCiteReferences(); } },
895 { "$latexbibfiles", [&]() { return CitationManager::instance().latexBibFiles(); } },
896 { "$papertype", [&]() { return paperType+"paper"; } },
897 { "$extralatexstylesheet", [&]() { return extraLatexStyleSheet(); } },
898 { "$languagesupport", [&]() { return theTranslator->latexLanguageSupportCommand(); } },
899 { "$latexfontenc", [&]() { return latexFontenc; } },
900 { "$latexfont", [&]() { return theTranslator->latexFont(); } },
901 { "$latexemojidirectory", [&]() { return latexEmojiDirectory; } },
902 { "$makeindex", [&]() { return makeIndex(); } },
903 { "$extralatexpackages", [&]() { return extraLatexPackages; } },
904 { "$latexspecialformulachars", [&]() { return latexSpecialFormulaChars; } },
905 { "$formulamacrofile", [&]() { return stripMacroFile; } },
906 { "$latex_batchmode", [&]() { return latex_batchmode(); } }
907 });
908
909 // remove conditional blocks
910 result = selectBlocks(result,
911 {
912 // marker is enabled
913 { "CITATIONS_PRESENT", !CitationManager::instance().empty() },
914 { "COMPACT_LATEX", compactLatex },
915 { "PDF_HYPERLINKS", pdfHyperlinks },
916 { "USE_PDFLATEX", usePdfLatex },
917 { "TIMESTAMP", timeStamp!=TIMESTAMP_t::NO },
918 { "LATEX_FONTENC", !latexFontenc.empty() },
919 { "FORMULA_MACROFILE", !formulaMacrofile.empty() },
920 { "PROJECT_NUMBER", !projectNumber.empty() }
922
923 result = removeEmptyLines(result.str());
924
925 return result;
926}
static CitationManager & instance()
Definition cite.cpp:86
bool empty() const
return true if there are no citations.
Definition cite.cpp:116
DString latexBibFiles()
lists the bibtex cite files in a comma separated list
Definition cite.cpp:572
const std::string & str() const
Definition dstring.h:634
virtual DString latexDocumentPost()
Definition translator.h:69
virtual DString trGeneratedAt(const DString &date, const DString &projName)=0
virtual DString latexFontenc()
Definition translator.h:54
virtual DString trCiteReferences()=0
virtual DString latexLanguageSupportCommand()=0
virtual DString trISOLang()=0
virtual DString latexFont()
Definition translator.h:55
virtual DString latexDocumentPre()
Definition translator.h:64
virtual DString trGeneratedBy()=0
#define Config_getEnumAsString(name)
Definition config.h:36
DString yearToString()
Returns the current year as a string.
Definition datetime.cpp:75
DString dateToString(DateTimeType includeTime)
Returns the current date, when includeTime is set also the time is provided.
Definition datetime.cpp:62
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
Definition dstring.cpp:480
Translator * theTranslator
Definition language.cpp:71
static DString extraLatexStyleSheet()
Definition latexgen.cpp:739
static DString latex_batchmode()
Definition latexgen.cpp:786
static const SelectionMarkerInfo latexMarkerInfo
Definition latexgen.cpp:55
void writeExtraLatexPackages(TextStream &t)
static DString makeIndex()
Definition latexgen.cpp:768
void writeLatexSpecialFormulaChars(TextStream &t)
Definition message.h:144
std::string removeEmptyLines(const std::string &s)
Definition stringutil.h:181
DString selectBlocks(const DString &s, const SelectionBlockList &blockList, const SelectionMarkerInfo &markerInfo)
remove disabled blocks and all block markers from s and return the result as a string
Definition util.cpp:5750
DString showDate(const DString &fmt)
Definition util.cpp:2634
DString substituteKeywords(const DString &file, const DString &s, const KeywordSubstitutionList &keywords)
Definition util.cpp:2561
DString projectLogoFile()
Definition util.cpp:2647
bool copyFile(const DString &src, const DString &dest)
Copies the contents of file with name src to the newly created file with name dest.
Definition util.cpp:5179
DString projectLogoSize()
Definition util.cpp:2666

References FileInfo::absFilePath(), Config_getBool, Config_getEnum, Config_getEnumAsString, Config_getString, convertToLaTeX(), copyFile(), Date, DateTime, dateToString(), CitationManager::empty(), DString::empty(), extraLatexStyleSheet(), FileInfo::fileName(), filterLatexString(), CitationManager::instance(), latex_batchmode(), CitationManager::latexBibFiles(), Translator::latexDocumentPost(), Translator::latexDocumentPre(), Translator::latexFont(), Translator::latexFontenc(), Translator::latexLanguageSupportCommand(), latexMarkerInfo, makeIndex(), projectLogoFile(), projectLogoSize(), removeEmptyLines(), selectBlocks(), showDate(), DString::str(), TextStream::str(), stripPath(), substitute(), substituteKeywords(), substituteLatexKeywords(), theTranslator, Time, Translator::trCiteReferences(), Translator::trGeneratedAt(), Translator::trGeneratedBy(), Translator::trISOLang(), writeExtraLatexPackages(), writeLatexSpecialFormulaChars(), and yearToString().

Referenced by LatexGenerator::endIndexSection(), LatexGenerator::init(), LatexGenerator::startIndexSection(), and substituteLatexKeywords().

◆ writeDefaultStyleSheet()

void writeDefaultStyleSheet ( TextStream & t)
static

Definition at line 686 of file latexgen.cpp.

687{
688 t << ResourceMgr::instance().getAsString("doxygen.sty");
689}
static ResourceMgr & instance()
Returns the one and only instance of this class.
DString getAsString(const DString &name) const
Gets the resource data as a C string.

References ResourceMgr::getAsString(), ResourceMgr::instance(), and writeDefaultStyleSheet().

Referenced by writeDefaultStyleSheet(), LatexGenerator::writeStyleInfo(), and LatexGenerator::writeStyleSheetFile().

◆ writeExtraLatexPackages()

void writeExtraLatexPackages ( TextStream & t)

Definition at line 2301 of file latexgen.cpp.

2302{
2303 // User-specified packages
2304 StringVector extraPackages = Config_getList(EXTRA_PACKAGES);
2305 if (!extraPackages.empty())
2306 {
2307 t << "% Packages requested by user\n";
2308 for (const auto &pkgName : extraPackages)
2309 {
2310 if ((pkgName[0] == '[') || (pkgName[0] == '{'))
2311 t << "\\usepackage" << pkgName << "\n";
2312 else
2313 t << "\\usepackage{" << pkgName << "}\n";
2314 }
2315 t << "\n";
2316 }
2317}

References Config_getList, and writeExtraLatexPackages().

Referenced by FormulaManager::createLatexFile(), substituteLatexKeywords(), and writeExtraLatexPackages().

◆ writeLatexMakefile()

void writeLatexMakefile ( )
static

Definition at line 367 of file latexgen.cpp.

368{
369 bool generateBib = !CitationManager::instance().empty();
370 DString fileName=Config_getString(LATEX_OUTPUT)+"/Makefile";
371 std::ofstream f = Portable::openOutputStream(fileName);
372 if (!f.is_open())
373 {
374 term("Could not open file {} for writing\n",fileName);
375 }
376 TextStream t(&f);
377 // inserted by KONNO Akihisa <konno@researchers.jp> 2002-03-05
378 DString latex_command = theTranslator->latexCommandName().quoted();
379 DString mkidx_command = Config_getString(MAKEINDEX_CMD_NAME).quoted();
380 DString bibtex_command = "bibtex";
381 DString manual_file = "refman";
382 const int latex_count = 8;
383 // end insertion by KONNO Akihisa <konno@researchers.jp> 2002-03-05
384 t << "LATEX_CMD?=" << latex_command << "\n"
385 << "MKIDX_CMD?=" << mkidx_command << "\n"
386 << "BIBTEX_CMD?=" << bibtex_command << "\n"
387 << "LATEX_COUNT?=" << latex_count << "\n"
388 << "MANUAL_FILE?=" << manual_file << "\n"
389 << "\n";
390 if (!Config_getBool(USE_PDFLATEX)) // use plain old latex
391 {
392 t << "all: $(MANUAL_FILE).dvi\n"
393 << "\n"
394 << "ps: $(MANUAL_FILE).ps\n"
395 << "\n"
396 << "pdf: $(MANUAL_FILE).pdf\n"
397 << "\n"
398 << "ps_2on1: $(MANUAL_FILE).ps\n"
399 << "\n"
400 << "pdf_2on1: $(MANUAL_FILE).pdf\n"
401 << "\n"
402 << "$(MANUAL_FILE).ps: $(MANUAL_FILE).dvi\n"
403 << "\tdvips -o $(MANUAL_FILE).ps $(MANUAL_FILE).dvi\n"
404 << "\n";
405 t << "$(MANUAL_FILE).pdf: $(MANUAL_FILE).ps\n";
406 t << "\tps2pdf $(MANUAL_FILE).ps $(MANUAL_FILE).pdf\n\n";
407 t << "$(MANUAL_FILE).dvi: clean $(MANUAL_FILE).tex doxygen.sty\n"
408 << "\techo \"Running latex...\"\n"
409 << "\t$(LATEX_CMD) $(MANUAL_FILE).tex || \\\n"
410 << "\tif [ $$? != 0 ] ; then \\\n"
411 << "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
412 << "\t false; \\\n"
413 << "\tfi\n"
414 << "\techo \"Running makeindex...\"\n"
415 << "\t$(MKIDX_CMD) $(MANUAL_FILE).idx\n";
416 if (generateBib)
417 {
418 t << "\techo \"Running bibtex...\"\n";
419 t << "\t$(BIBTEX_CMD) $(MANUAL_FILE)\n";
420 t << "\techo \"Rerunning latex....\"\n";
421 t << "\t$(LATEX_CMD) $(MANUAL_FILE).tex || \\\n"
422 << "\tif [ $$? != 0 ] ; then \\\n"
423 << "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
424 << "\t false; \\\n"
425 << "\tfi\n";
426 }
427 t << "\techo \"Rerunning latex....\"\n"
428 << "\t$(LATEX_CMD) $(MANUAL_FILE).tex\n"
429 << "\tlatex_count=$(LATEX_COUNT) ; \\\n"
430 << "\twhile grep -E -s 'Rerun (LaTeX|to get cross-references right|to get bibliographical references right)' $(MANUAL_FILE).log && [ $$latex_count -gt 0 ] ;\\\n"
431 << "\t do \\\n"
432 << "\t echo \"Rerunning latex....\" ;\\\n"
433 << "\t $(LATEX_CMD) $(MANUAL_FILE).tex ; \\\n"
434 << "\t $(LATEX_CMD) $(MANUAL_FILE).tex || \\\n"
435 << "\t if [ $$? != 0 ] ; then \\\n"
436 << "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
437 << "\t false; \\\n"
438 << "\t fi; \\\n"
439 << "\t latex_count=`expr $$latex_count - 1` ;\\\n"
440 << "\t done\n"
441 << "\t$(MKIDX_CMD) $(MANUAL_FILE).idx\n"
442 << "\t$(LATEX_CMD) $(MANUAL_FILE).tex || \\\n"
443 << "\tif [ $$? != 0 ] ; then \\\n"
444 << "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
445 << "\t false; \\\n"
446 << "\tfi\n"
447 << "$(MANUAL_FILE).ps: $(MANUAL_FILE).ps\n"
448 << "\tpsnup -2 $(MANUAL_FILE).ps >$(MANUAL_FILE).ps\n"
449 << "\n"
450 << "$(MANUAL_FILE).pdf: $(MANUAL_FILE).ps\n"
451 << "\tps2pdf $(MANUAL_FILE).ps $(MANUAL_FILE).pdf\n";
452 }
453 else // use pdflatex for higher quality output
454 {
455 t << "all: $(MANUAL_FILE).pdf\n\n"
456 << "pdf: $(MANUAL_FILE).pdf\n\n";
457 t << "$(MANUAL_FILE).pdf: clean $(MANUAL_FILE).tex\n";
458 t << "\t$(LATEX_CMD) $(MANUAL_FILE) || \\\n"
459 << "\tif [ $$? != 0 ] ; then \\\n"
460 << "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
461 << "\t false; \\\n"
462 << "\tfi\n";
463 t << "\t$(MKIDX_CMD) $(MANUAL_FILE).idx\n";
464 if (generateBib)
465 {
466 t << "\t$(BIBTEX_CMD) $(MANUAL_FILE)\n";
467 t << "\t$(LATEX_CMD) $(MANUAL_FILE) || \\\n"
468 << "\tif [ $$? != 0 ] ; then \\\n"
469 << "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
470 << "\t false; \\\n"
471 << "\tfi\n";
472 }
473 t << "\t$(LATEX_CMD) $(MANUAL_FILE) || \\\n"
474 << "\tif [ $$? != 0 ] ; then \\\n"
475 << "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
476 << "\t false; \\\n"
477 << "\tfi\n"
478 << "\tlatex_count=$(LATEX_COUNT) ; \\\n"
479 << "\twhile grep -E -s 'Rerun (LaTeX|to get cross-references right|to get bibliographical references right)' $(MANUAL_FILE).log && [ $$latex_count -gt 0 ] ;\\\n"
480 << "\t do \\\n"
481 << "\t echo \"Rerunning latex....\" ;\\\n"
482 << "\t $(LATEX_CMD) $(MANUAL_FILE) || \\\n"
483 << "\t if [ $$? != 0 ] ; then \\\n"
484 << "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
485 << "\t false; \\\n"
486 << "\t fi; \\\n"
487 << "\t latex_count=`expr $$latex_count - 1` ;\\\n"
488 << "\t done\n"
489 << "\t$(MKIDX_CMD) $(MANUAL_FILE).idx\n"
490 << "\t$(LATEX_CMD) $(MANUAL_FILE) || \\\n"
491 << "\tif [ $$? != 0 ] ; then \\\n"
492 << "\t \\echo \"Please consult $(MANUAL_FILE).log to see the error messages\" ; \\\n"
493 << "\t false; \\\n"
494 << "\tfi\n";
495 }
496
497 t << "\n"
498 << "clean:\n"
499 << "\trm -f "
500 << "*.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl $(MANUAL_FILE).pdf\n";
501}
DString quoted() const
Definition dstring.h:357
virtual DString latexCommandName()
Definition translator.h:73
#define term(fmt,...)
Definition message.h:137
std::ofstream openOutputStream(const DString &name, bool append=false)
Definition portable.cpp:648

References Config_getBool, Config_getString, CitationManager::empty(), CitationManager::instance(), Translator::latexCommandName(), Portable::openOutputStream(), DString::quoted(), term, theTranslator, and writeLatexMakefile().

Referenced by LatexGenerator::init(), and writeLatexMakefile().

◆ writeLatexSpecialFormulaChars()

void writeLatexSpecialFormulaChars ( TextStream & t)

Definition at line 2319 of file latexgen.cpp.

2320{
2321 unsigned char minus[4]; // Superscript minus
2322 unsigned char sup2[3]; // Superscript two
2323 unsigned char sup3[3];
2324 minus[0]= 0xE2;
2325 minus[1]= 0x81;
2326 minus[2]= 0xBB;
2327 minus[3]= 0;
2328 sup2[0]= 0xC2;
2329 sup2[1]= 0xB2;
2330 sup2[2]= 0;
2331 sup3[0]= 0xC2;
2332 sup3[1]= 0xB3;
2333 sup3[2]= 0;
2334
2335 t << "\\ifPDFTeX\n";
2336 t << "\\usepackage{newunicodechar}\n";
2337 // taken from the newunicodechar package and removed the warning message
2338 // actually forcing to redefine the unicode character
2339 t << " \\makeatletter\n"
2340 " \\def\\doxynewunicodechar#1#2{%\n"
2341 " \\@tempswafalse\n"
2342 " \\edef\\nuc@tempa{\\detokenize{#1}}%\n"
2343 " \\if\\relax\\nuc@tempa\\relax\n"
2344 " \\nuc@emptyargerr\n"
2345 " \\else\n"
2346 " \\edef\\@tempb{\\expandafter\\@car\\nuc@tempa\\@nil}%\n"
2347 " \\nuc@check\n"
2348 " \\if@tempswa\n"
2349 " \\@namedef{u8:\\nuc@tempa}{#2}%\n"
2350 " \\fi\n"
2351 " \\fi\n"
2352 " }\n"
2353 " \\makeatother\n";
2354
2355 t << " \\doxynewunicodechar{" << minus << "}{${}^{-}$}% Superscript minus\n"
2356 " \\doxynewunicodechar{" << sup2 << "}{${}^{2}$}% Superscript two\n"
2357 " \\doxynewunicodechar{" << sup3 << "}{${}^{3}$}% Superscript three\n"
2358 "\n";
2359 t << "\\fi\n";
2360}

References writeLatexSpecialFormulaChars().

Referenced by FormulaManager::createLatexFile(), substituteLatexKeywords(), and writeLatexSpecialFormulaChars().

◆ writeMakeBat()

void writeMakeBat ( )
static

Definition at line 503 of file latexgen.cpp.

504{
505#if defined(_MSC_VER)
506 DString dir=Config_getString(LATEX_OUTPUT);
507 DString fileName=dir+"/make.bat";
508 DString latex_command = theTranslator->latexCommandName().quoted();
509 DString mkidx_command = Config_getString(MAKEINDEX_CMD_NAME).quoted();
510 DString bibtex_command = "bibtex";
511 DString manual_file = "refman";
512 const int latex_count = 8;
513 bool generateBib = !CitationManager::instance().empty();
514 std::ofstream t = Portable::openOutputStream(fileName);
515 if (!t.is_open())
516 {
517 term("Could not open file {} for writing\n",fileName);
518 }
519 t << "pushd %~dp0\r\n";
520 t << "if not %errorlevel% == 0 goto :end1\r\n";
521 t << "\r\n";
522 t << "set ORG_LATEX_CMD=%LATEX_CMD%\r\n";
523 t << "set ORG_MKIDX_CMD=%MKIDX_CMD%\r\n";
524 t << "set ORG_BIBTEX_CMD=%BIBTEX_CMD%\r\n";
525 t << "set ORG_LATEX_COUNT=%LATEX_COUNT%\r\n";
526 t << "set ORG_MANUAL_FILE=%MANUAL_FILE%\r\n";
527 t << "if \"X\"%LATEX_CMD% == \"X\" set LATEX_CMD=" << latex_command << "\r\n";
528 t << "if \"X\"%MKIDX_CMD% == \"X\" set MKIDX_CMD=" << mkidx_command << "\r\n";
529 t << "if \"X\"%BIBTEX_CMD% == \"X\" set BIBTEX_CMD=" << bibtex_command << "\r\n";
530 t << "if \"X\"%LATEX_COUNT% == \"X\" set LATEX_COUNT=" << latex_count << "\r\n";
531 t << "if \"X\"%MANUAL_FILE% == \"X\" set MANUAL_FILE=" << manual_file << "\r\n";
532 t << "\r\n";
533 t << "del /s /f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl %MANUAL_FILE%.pdf\r\n\r\n";
534 t << "\r\n";
535 if (!Config_getBool(USE_PDFLATEX)) // use plain old latex
536 {
537 t << "%LATEX_CMD% %MANUAL_FILE%.tex\r\n";
538 t << "@if ERRORLEVEL 1 goto :error\r\n";
539 t << "echo ----\r\n";
540 t << "%MKIDX_CMD% %MANUAL_FILE%.idx\r\n";
541 if (generateBib)
542 {
543 t << "%BIBTEX_CMD% %MANUAL_FILE%\r\n";
544 t << "echo ----\r\n";
545 t << "\t%LATEX_CMD% %MANUAL_FILE%.tex\r\n";
546 t << "@if ERRORLEVEL 1 goto :error\r\n";
547 }
548 t << "setlocal enabledelayedexpansion\r\n";
549 t << "set count=%LAT#EX_COUNT%\r\n";
550 t << ":repeat\r\n";
551 t << "set content=X\r\n";
552 t << "for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun LaTeX\" %MANUAL_FILE%.log' ) do set content=\"%%~T\"\r\n";
553 t << "if !content! == X for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun to get cross-references right\" %MANUAL_FILE%.log' ) do set content=\"%%~T\"\r\n";
554 t << "if !content! == X for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun to get bibliographical references right\" %MANUAL_FILE%.log' ) do set content=\"%%~T\"\r\n";
555 t << "if !content! == X goto :skip\r\n";
556 t << "set /a count-=1\r\n";
557 t << "if !count! EQU 0 goto :skip\r\n\r\n";
558 t << "echo ----\r\n";
559 t << "%LATEX_CMD% %MANUAL_FILE%.tex\r\n";
560 t << "@if ERRORLEVEL 1 goto :error\r\n";
561 t << "goto :repeat\r\n";
562 t << ":skip\r\n";
563 t << "endlocal\r\n";
564 t << "%MKIDX_CMD% %MANUAL_FILE%.idx\r\n";
565 t << "%LATEX_CMD% %MANUAL_FILE%.tex\r\n";
566 t << "@if ERRORLEVEL 1 goto :error\r\n";
567 t << "dvips -o %MANUAL_FILE%.ps %MANUAL_FILE%.dvi\r\n";
569 t << " -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "
570 "-sOutputFile=%MANUAL_FILE%.pdf -c save pop -f %MANUAL_FILE%.ps\r\n";
571 }
572 else // use pdflatex
573 {
574 t << "%LATEX_CMD% %MANUAL_FILE%\r\n";
575 t << "@if ERRORLEVEL 1 goto :error\r\n";
576 t << "echo ----\r\n";
577 t << "%MKIDX_CMD% %MANUAL_FILE%.idx\r\n";
578 if (generateBib)
579 {
580 t << "%BIBTEX_CMD% %MANUAL_FILE%\r\n";
581 t << "%LATEX_CMD% %MANUAL_FILE%\r\n";
582 t << "@if ERRORLEVEL 1 goto :error\r\n";
583 }
584 t << "echo ----\r\n";
585 t << "%LATEX_CMD% %MANUAL_FILE%\r\n";
586 t << "@if ERRORLEVEL 1 goto :error\r\n";
587 t << "\r\n";
588 t << "setlocal enabledelayedexpansion\r\n";
589 t << "set count=%LATEX_COUNT%\r\n";
590 t << ":repeat\r\n";
591 t << "set content=X\r\n";
592 t << "for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun LaTeX\" %MANUAL_FILE%.log' ) do set content=\"%%~T\"\r\n";
593 t << "if !content! == X for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun to get cross-references right\" %MANUAL_FILE%.log' ) do set content=\"%%~T\"\r\n";
594 t << "if !content! == X for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun to get bibliographical references right\" %MANUAL_FILE%.log' ) do set content=\"%%~T\"\r\n";
595 t << "if !content! == X goto :skip\r\n";
596 t << "set /a count-=1\r\n";
597 t << "if !count! EQU 0 goto :skip\r\n\r\n";
598 t << "echo ----\r\n";
599 t << "%LATEX_CMD% %MANUAL_FILE%\r\n";
600 t << "@if ERRORLEVEL 1 goto :error\r\n";
601 t << "goto :repeat\r\n";
602 t << ":skip\r\n";
603 t << "endlocal\r\n";
604 t << "%MKIDX_CMD% %MANUAL_FILE%.idx\r\n";
605 t << "%LATEX_CMD% %MANUAL_FILE%\r\n";
606 t << "@if ERRORLEVEL 1 goto :error\r\n";
607 }
608 t<< "\r\n";
609 t << "goto :end\r\n";
610 t << ":error\r\n";
611 t << "@echo ===============\r\n";
612 t << "@echo Please consult %MANUAL_FILE%.log to see the error messages\r\n";
613 t << "@echo ===============\r\n";
614 t<< "\r\n";
615 t<< ":end\r\n";
616 t<< "@REM reset environment\r\n";
617 t<< "popd\r\n";
618 t<< "set LATEX_CMD=%ORG_LATEX_CMD%\r\n";
619 t<< "set ORG_LATEX_CMD=\r\n";
620 t<< "set MKIDX_CMD=%ORG_MKIDX_CMD%\r\n";
621 t<< "set ORG_MKIDX_CMD=\r\n";
622 t<< "set BIBTEX_CMD=%ORG_BIBTEX_CMD%\r\n";
623 t<< "set ORG_BIBTEX_CMD=\r\n";
624 t<< "set MANUAL_FILE=%ORG_MANUAL_FILE%\r\n";
625 t<< "set ORG_MANUAL_FILE=\r\n";
626 t<< "set LATEX_COUNT=%ORG_LATEX_COUNT%\r\n";
627 t<< "set ORG_LATEX_COUNT=\r\n";
628 t<< "\r\n";
629 t<< ":end1\r\n";
630#endif
631}
const char * ghostScriptCommand()
Definition portable.cpp:437

References Config_getBool, Config_getString, CitationManager::empty(), Portable::ghostScriptCommand(), CitationManager::instance(), Translator::latexCommandName(), Portable::openOutputStream(), DString::quoted(), term, theTranslator, and writeMakeBat().

Referenced by LatexGenerator::init(), and writeMakeBat().

Variable Documentation

◆ g_footer

DString g_footer
static

Definition at line 53 of file latexgen.cpp.

Referenced by LatexGenerator::endIndexSection(), and LatexGenerator::init().

◆ g_footer_file

DString g_footer_file
static

Definition at line 54 of file latexgen.cpp.

Referenced by LatexGenerator::endIndexSection(), and LatexGenerator::init().

◆ g_header

DString g_header
static

Definition at line 51 of file latexgen.cpp.

Referenced by LatexGenerator::init(), and LatexGenerator::startIndexSection().

◆ g_header_file

DString g_header_file
static

Definition at line 52 of file latexgen.cpp.

Referenced by LatexGenerator::init(), and LatexGenerator::startIndexSection().

◆ latexMarkerInfo

const SelectionMarkerInfo latexMarkerInfo = { '%', "%%BEGIN ",8 ,"%%END ",6, "",0 }
static

Definition at line 55 of file latexgen.cpp.

Referenced by LatexGenerator::init(), and substituteLatexKeywords().