Skip to content

Commit 19b3ab1

Browse files
committed
first commit
0 parents  commit 19b3ab1

19 files changed

+6072
-0
lines changed

.vscode/settings.json

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"files.associations": {
3+
"iostream": "cpp",
4+
"memory": "cpp",
5+
"vector": "cpp",
6+
"cctype": "cpp",
7+
"clocale": "cpp",
8+
"cmath": "cpp",
9+
"cstdarg": "cpp",
10+
"cstddef": "cpp",
11+
"cstdio": "cpp",
12+
"cstdlib": "cpp",
13+
"cstring": "cpp",
14+
"ctime": "cpp",
15+
"cwchar": "cpp",
16+
"cwctype": "cpp",
17+
"array": "cpp",
18+
"atomic": "cpp",
19+
"hash_map": "cpp",
20+
"strstream": "cpp",
21+
"bit": "cpp",
22+
"*.tcc": "cpp",
23+
"bitset": "cpp",
24+
"cfenv": "cpp",
25+
"charconv": "cpp",
26+
"chrono": "cpp",
27+
"codecvt": "cpp",
28+
"compare": "cpp",
29+
"complex": "cpp",
30+
"concepts": "cpp",
31+
"condition_variable": "cpp",
32+
"cstdint": "cpp",
33+
"deque": "cpp",
34+
"forward_list": "cpp",
35+
"list": "cpp",
36+
"map": "cpp",
37+
"set": "cpp",
38+
"string": "cpp",
39+
"unordered_map": "cpp",
40+
"unordered_set": "cpp",
41+
"exception": "cpp",
42+
"algorithm": "cpp",
43+
"functional": "cpp",
44+
"iterator": "cpp",
45+
"memory_resource": "cpp",
46+
"numeric": "cpp",
47+
"optional": "cpp",
48+
"random": "cpp",
49+
"ratio": "cpp",
50+
"regex": "cpp",
51+
"source_location": "cpp",
52+
"string_view": "cpp",
53+
"system_error": "cpp",
54+
"tuple": "cpp",
55+
"type_traits": "cpp",
56+
"utility": "cpp",
57+
"fstream": "cpp",
58+
"initializer_list": "cpp",
59+
"iomanip": "cpp",
60+
"iosfwd": "cpp",
61+
"istream": "cpp",
62+
"limits": "cpp",
63+
"mutex": "cpp",
64+
"new": "cpp",
65+
"numbers": "cpp",
66+
"ostream": "cpp",
67+
"semaphore": "cpp",
68+
"shared_mutex": "cpp",
69+
"span": "cpp",
70+
"sstream": "cpp",
71+
"stdexcept": "cpp",
72+
"stop_token": "cpp",
73+
"streambuf": "cpp",
74+
"thread": "cpp",
75+
"cinttypes": "cpp",
76+
"typeindex": "cpp",
77+
"typeinfo": "cpp",
78+
"variant": "cpp",
79+
"format": "cpp",
80+
"stdfloat": "cpp"
81+
}
82+
}

CMakeLists.txt

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
cmake_minimum_required(VERSION 3.10.0)
2+
project(LatexGenCpp VERSION 0.1.0 LANGUAGES C CXX)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
set(CMAKE_CXX_STANDARD_REQUIRED True)
6+
7+
include_directories(
8+
${CMAKE_CURRENT_SOURCE_DIR}/include
9+
)
10+
11+
set(src
12+
src/latexgen.cpp
13+
)
14+
15+
# Bibliothèque principale
16+
add_library(LatexGenCpp SHARED
17+
${src}
18+
)
19+
20+
# Adding a version to the library
21+
set_target_properties(LatexGenCpp PROPERTIES VERSION 0.1.0 SOVERSION 0)
22+
23+
target_include_directories(LatexGenCpp
24+
PUBLIC
25+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
26+
$<INSTALL_INTERFACE:include>
27+
)
28+
29+
30+
# Création de l'exemple multilingue
31+
add_executable(multilingual_example
32+
example/multilingual_example.cpp
33+
)
34+
35+
target_link_libraries(multilingual_example
36+
PRIVATE
37+
LatexGenCpp
38+
)
39+
40+
41+
# Création de l'exemple d'article
42+
add_executable(article_example
43+
example/article_example.cpp
44+
)
45+
46+
target_link_libraries(article_example
47+
PRIVATE
48+
LatexGenCpp
49+
)
50+
51+
# Création de l'exemple de livre
52+
add_executable(book_example
53+
example/book_example.cpp
54+
)
55+
56+
target_link_libraries(book_example
57+
PRIVATE
58+
LatexGenCpp
59+
)
60+
61+
# Création de l'exemple d'index
62+
add_executable(index_example
63+
example/index_example.cpp
64+
)
65+
66+
target_link_libraries(index_example
67+
PRIVATE
68+
LatexGenCpp
69+
)
70+
71+
# Création de l'exemple de présentation
72+
add_executable(presentation_example
73+
example/presentation_example.cpp
74+
)
75+
76+
target_link_libraries(presentation_example
77+
PRIVATE
78+
LatexGenCpp
79+
)
80+
81+
# Création de l'exemple de rapport
82+
add_executable(report_example
83+
example/report_example.cpp
84+
)
85+
86+
target_link_libraries(report_example
87+
PRIVATE
88+
LatexGenCpp
89+
)
90+
91+
# Configuration de l'installation
92+
install(TARGETS LatexGenCpp
93+
LIBRARY DESTINATION lib
94+
ARCHIVE DESTINATION lib
95+
)
96+
97+
install(DIRECTORY include/ DESTINATION include)
98+
99+
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
100+
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
101+
set(CPACK_GENERATOR "DEB")
102+
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Sofiane KHELLADI") #required
103+
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
104+
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.4)")
105+
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
106+
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "A C++ library for generating LaTeX documents.") #added description
107+
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://codes.khelladi.page") #added homepage
108+
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") #added priority
109+
110+
include(CPack)

README.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# LatexGenC++
2+
3+
A C++ library for programmatically generating LaTeX documents.
4+
5+
## Overview
6+
7+
LatexGenC++ is a comprehensive C++ library that allows programmatic generation of LaTeX documents. It provides an object-oriented API for creating various types of LaTeX documents, including articles, reports, books, and presentations, with support for multilingual content.
8+
9+
## Features
10+
11+
- **Multiple Document Types**: Support for articles, reports, books, and Beamer presentations
12+
- **Structured Content**: Easy management of sections, subsections, chapters, parts, etc.
13+
- **Rich Elements**: Figures, tables, equations, lists, theorems, algorithms
14+
- **Bibliography Management**: Two methods for handling bibliographies:
15+
- Using external .bib files
16+
- Creating references programmatically
17+
- **Multilingual Support**: 11 languages including English, French, German, Spanish, etc.
18+
- **Custom Templates**: Apply consistent styling across documents
19+
- **Index Generation**: Support for creating document indexes
20+
21+
## Installation
22+
23+
### Prerequisites
24+
25+
- C++ compiler with C++17 support
26+
- CMake (version 3.10 or higher)
27+
28+
### Build and Install
29+
30+
```bash
31+
# Clone the repository
32+
git clone https://github.com/yourusername/LatexGenCpp.git
33+
34+
# Create a build directory
35+
cd LatexGenCpp
36+
mkdir build && cd build
37+
38+
# Configure and build
39+
cmake ..
40+
make
41+
42+
# Install (optional)
43+
sudo make install
44+
```
45+
46+
## Usage Examples
47+
48+
A detailed documentation is available in the `doc/` directory. Below are some basic usage examples to get you started. (hers is the link to the documentation: [FR](doc/DOCUMENTATION_FR.md), [EN](doc/DOCUMENTATION_EN.md))
49+
50+
### Creating a Simple Article
51+
52+
```cpp
53+
#include "latexgen.h"
54+
#include <iostream>
55+
56+
using namespace LatexGen;
57+
58+
int main() {
59+
// Create an article
60+
Article article("My Document Title", "Author Name", "Today");
61+
62+
// Add a section
63+
Section section("Introduction", Section::Level::SECTION);
64+
section.addContent("This is the content of my first section.");
65+
66+
// Add the section to the article
67+
article.addSection(section);
68+
69+
// Save the document
70+
if (article.saveToFile("output", "mydocument.tex")) {
71+
std::cout << "Document created successfully!" << std::endl;
72+
}
73+
74+
return 0;
75+
}
76+
```
77+
78+
### Adding Figures and Tables
79+
80+
```cpp
81+
// Adding a figure
82+
auto figure = document.addFigure(
83+
"image.png", // Image path
84+
"Figure Caption", // Caption
85+
"fig:label", // Label for reference
86+
"0.7\\textwidth", // Width
87+
"htbp" // Position
88+
);
89+
90+
// Adding a table
91+
std::vector<std::string> headers = {"Column 1", "Column 2", "Column 3"};
92+
auto table = document.addTable(
93+
headers, // Column headers
94+
"Table Caption", // Caption
95+
"tab:label", // Label for reference
96+
"htbp" // Position
97+
);
98+
99+
// Adding rows to the table
100+
table->addRow({"Value 1", "Value 2", "Value 3"});
101+
table->addRow({"Value 4", "Value 5", "Value 6"});
102+
```
103+
104+
### Using Bibliographies
105+
106+
```cpp
107+
// Method 1: Using an existing external .bib file
108+
Bibliography biblio("references", BibStyle::IEEE);
109+
document.setBibliography(biblio);
110+
111+
// Method 2: Creating references programmatically
112+
Bibliography biblio2;
113+
biblio2.setStyle(BibStyle::IEEE);
114+
115+
// Create an article entry
116+
BibEntry article("smith2023", BibEntry::EntryType::ARTICLE);
117+
article.addField("author", "John Smith");
118+
article.addField("title", "Introduction to LaTeX Programming");
119+
article.addField("journal", "Journal of Document Engineering");
120+
article.addField("year", "2023");
121+
article.addField("volume", "42");
122+
article.addField("pages", "123--456");
123+
124+
// Add the entry to the bibliography
125+
biblio2.addEntry(article);
126+
127+
// Generate the .bib file
128+
biblio2.generateBibFile("output");
129+
130+
// Use the bibliography in the document
131+
document.setBibliography(biblio2);
132+
133+
// Cite a reference
134+
document.addRawContent("According to " + document.cite("smith2023") + ", the theory is valid.");
135+
```
136+
137+
## Documentation
138+
139+
For a comprehensive guide to all features, see the examples in the `example/` directory:
140+
141+
- `article_example.cpp`: Creating a scientific article
142+
- `book_example.cpp`: Creating a book with parts, chapters, and appendices
143+
- `report_example.cpp`: Creating a technical report
144+
- `presentation_example.cpp`: Creating a Beamer presentation
145+
- `index_example.cpp`: Using indexing features
146+
- `multilingual_example.cpp`: Creating documents in different languages
147+
148+
## License
149+
150+
This project is licensed under the GPL-3.0 License. See the [LICENSE](LICENSE) file for details.
151+
152+
## Author
153+
154+
Sofiane KHELLADI
155+
156+
## Contributing
157+
158+
Contributions are welcome! Please feel free to submit a Pull Request.

0 commit comments

Comments
 (0)