4

First of all I think I need to apologize for the uninitiated beginner question as I suspect I might want LaTeX to do something weird, but anyway here goes. Also I might not be using terms and names appropriate to LaTeX specifically so bear with me.

I am a senior developer with several years of experience in both backend and frontend.

I thought it would be a nice idea to get into LaTeX while writing my CV in it. I found Overleaf and thought I would use that for my trials.

I did try some basic examples, but immediately tried to investigate some best practices/recommended ways of structuring the documents and possibly create some abstractions/reusable parts.

TLDR: I want the main document to possibly only contain usages of named "macros" (created by me to match the sections of the CV) with parameter values (Name, email, job name, description, year from/to, etc.). Ideally the main document would not contain (m)any low-level TeX commands.

Here's what I wanted to achieve for my CV document:

  • create reusable defined styles to use throughout the document
  • create "macros"/"functions" for (repeating) sections of the document so the main document could be as simple/clean as possible, allowing me to add/change stuff easily (I want good decomposition and maintainability, clean code)
  • regarding styling I think I am maybe wrongly clinging to the HTML/CSS analogy and looking for something similar in LaTeX

In the end I got frustrated and wrote my CV in Scribus. I still find it compelling to try the TeX way, but I am not sure if what I want is possible.

I was convinced something like this had to be possible in LaTeX and I am not lazy to read manuals, but maybe I didn't google the right things. If you can kindly refer me to some appropriate documentation I can read up on my own. Thanx

New contributor
Jakub Hlavatý is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
4
  • 1
    Hmm, not sure what your relevant question is …?
    – MS-SPO
    Commented Sep 5 at 11:33
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Sep 5 at 12:01
  • Every package comes with a manual (usually PDF). There are also books which cover many packages, but they get dated quickly. Commented Sep 5 at 14:09
  • Yes, this can be done in TeX. The usual idea is that your macros/commands would be in the preamble between the \documentclass and \begin{document}. There are many packages that would help you create such commands. If you want to abstract your preamble into its own file, you would create a style or class file like the current answer. But at the moment, your question is about the same as a question on StackOverflow that says "can someone write a program that does the following...". Here (and there), we're more looking for questions that say "I have the following bit that's not working."
    – Teepeemm
    Commented 2 days ago

1 Answer 1

4

It sounds like you might like to create your own .cls file, say jakub.cls

jakub.cls

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{jakub}[2024/09/05 (Jakub, all rights reserved)]

% switch for option 1
\newif\ifoption@i
\option@ifalse

\DeclareOption{option1}{%
  \typeout{Jakub's class, option 1 specified!}
\option@ifalse}

\ProcessOptions\relax
\LoadClass[11pt]{article}

\newcommand{\jakubsfirstcommand}{Jakub's class}
\endinput

which you can then use as follows, for example

\documentclass{jakub}

\begin{document}

\jakubsfirstcommand
\end{document}

Or, using the optional argument

\documentclass[option1]{jakub}

\begin{document}

\jakubsfirstcommand
\end{document}

Perhaps Where do I place my own .sty or .cls files, to make them available to all my .tex files? will be helpful as to where this might live.


Alternatively, you might like to use a style file instead, say jakub.sty

jakub.sty

\ProvidesPackage{jakub}[2024/09/05 (Jakub, all rights reserved)]

% switch for option 1
\newif\ifoption@i
\option@ifalse

\DeclareOption{option1}{%
  \typeout{Jakub's style file, option 1 specified!}
\option@ifalse}

\ProcessOptions\relax
\newcommand{\jakubsfirstcommand}{Jakub's style}
\endinput

which you can use as

\documentclass{article}
\usepackage[option1]{jakub}

\begin{document}

\jakubsfirstcommand
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .