# Load the tinytex package
library(tinytex)
# Define the image path
image_path <- "C:/Users/Tonmoy/Downloads/0_ilw552fVUGbwIzbE.jpg"
# Create a more advanced LaTeX document
tex_file <- "advanced_document.tex"
writeLines(c(
"\\documentclass{article}",
"\\usepackage{graphicx}", # Package for including graphics
"\\usepackage{amsmath}", # Package for advanced math typesetting
"\\usepackage{hyperref}", # Package for hyperlinks
"\\title{Advanced LaTeX Document}", # Title of the document
"\\author{Tanmoy Mishra}", # Author of the document
"\\date{\\today}", # Date
"\\begin{document}",
"\\maketitle", # Generate the title
"\\tableofcontents", # Generate the table of contents
"\\newpage", # Start a new page
"\\section{Introduction}",
"This is the introduction section. You can write an overview of the document here.",
"\\section{Methodology}",
"This section describes the methodology used in this document.",
"\\subsection{Data Collection}",
"Details about data collection methods.",
"\\subsection{Data Analysis}",
"Details about data analysis methods.",
"\\section{Results}",
"This section presents the results of the study.",
"\\subsection{Descriptive Statistics}",
"Here are some descriptive statistics of the data.",
"\\begin{tabular}{|c|c|c|}",
"\\hline",
"Statistic & Value 1 & Value 2 \\\\",
"\\hline",
"Mean & 10 & 20 \\\\",
"Median & 5 & 15 \\\\",
"\\hline",
"\\end{tabular}",
"\\subsection{Figures}",
"This section includes figures to illustrate the results.",
"Figure \\ref{fig:example} shows an example figure.",
"\\begin{figure}[h]",
"\\centering",
paste0("\\includegraphics[width=0.5\\textwidth]{", image_path, "}"),
"\\caption{Example figure}",
"\\label{fig:example}",
"\\end{figure}",
"\\section{Conclusion}",
"This section concludes the document.Summarize your findings and mention
future work.",
"\\section{References}",
"Here you can list your references using the appropriate bibliography style.",
"\\end{document}"
), tex_file)
# Compile the document
tinytex::pdflatex(tex_file)
# Open the generated PDF
browseURL("advanced_document.pdf")