GeneralHelp to build a simple template

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
otyugh
Posts: 4
Joined: Mon Jun 17, 2019 1:21 pm

Help to build a simple template

Post by otyugh »

Hey,
I just finished my "simple template for french guys". There is one last thing I don"t get to do, is how to make a "conditionality" on a variable. Let review my actual template below.

%A4
\documentclass[10pt,a4paper]{article}

%french/europe
\usepackage[frenchb]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[unicode=true]{hyperref}
\usepackage{eurosym}

%Wokaround (pandoc complains otherwise)
\def\tightlist{}

%images
\usepackage{graphicx}

%interligne plus ahéré
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}

\begin{document}
\begin{titlepage}
\centering
\rule{\textwidth}{.75pt}\vskip25pt
{\bfseries\Huge $title$}
\vfill
\includegraphics[width=8cm]{logo.png}
\vfill\vfill
{\normalsize $author$\vskip5pt}
PDF généré le \today\vskip5pt
\rule{\textwidth}{.75pt}
\end{titlepage}

$if(toc)$
{
\hypersetup{linkcolor=black}
\setcounter{tocdepth}{$toc-depth$}
\tableofcontents
%\pagebreak
}
$endif$

$body$
\end{document}


What I want to improve is the line "\includegraphics[width=8cm]{img/logo.png}" ; I'd want "img/logo.png" to be a variable loaded from the document, and if not set, or empty, or with a path leading to a non-existing file, to do an alternate thing instead of crashing.

Could you give me a pointer on to what I should do/where I should read ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply