Category: Data

  • Managing My Finances as an Expat

    Managing My Finances as an Expat

    As a Singaporean living and working in Denmark, having bank accounts, savings and expenses both in Denmark and Singapore have made tracking my finances somewhat complicated.

    Money gets transferred across geographies… I earn, save and spend across different accounts… and waters get even muddier when I no longer just keep cash in the bank, but also invest in stocks and bonds.

    What are people saying?

    I knew I had to keep a close eye on my finances. Quick Googling suggests these for emergency funds and holding cash:

    • Emergency fund: Keep 3 to 6 months’ worth of essential living expenses in a liquid savings account.
    • Portfolio cash: Limit general cash or cash equivalents to roughly 2% to 10% of your total investment portfolio unless you have a major purchase planned within 12 to 24 months.

    CNBC also recommends retirement benchmarks by decades:

    • Age 30: 1x your annual salary
    • Age 40: 3x your annual salary
    • Age 50: 6x your annual salary
    • Age 60: 8x your annual salary
    • Age 67: 10x your annual salary

    But my numbers were everywhere in different accounts, different currencies, and they fluctuate depending on market conditions. I usually only had a hunch of how much I made and how much I spent, but nothing precise about my net-worth.

    How do I get an overview of everything?

    I started with a simple Excel file that slowly got more complicated. And I’m sharing a simple version of my Excel file in this post.

    I’ve used it over a few years. It has kept me on my toes all this while, and I get to do extra shopping 🛍 or have a couple extra takeouts 🥡 without guilt when I can see that I (or mostly the market) have made a good month of savings.

    In adult (and boring) terms, I could also start having clearer ideas and projections about when a home or big-ticket purchases become plausible, with such an overview.

    The Excel file looks like this:

    And it’s available ✨ here

    What are we looking at?

    From left to right, I track my finances at the start of every month, so 12 repetitions of the same set of cells for a whole year.

    From top to bottom, I start with a quick glance of all my money across my 3 accounts (2 in Denmark, 1 in Singapore), before diving into the breakdown across all these accounts.

    Month-on-month savings show the savings (or losses) made from the current month to the previous month. Untouchables is money I have in my Danish pension that is not immediately available, hence the name.

    I have accounts in 2 currencies, hence the SGD and DKK columns, and I eventually sum them up in DKK, since I’m financially more active in Denmark.

    The Quick Overview

    Each row is just the amount of money I have in each of my bank account. The green cells are where I input amounts of money, either in SGD or DKK, and they get summed up automatically in DKK in the subtotal rows.

    Asset Breakdown

    The breakdown gets a bit more interesting. This depends on brokerages, but the brokerage that I’m using lets me see values in different sub-accounts I have with them, differentiated by cash and positions held.

    Each row represents the type of asset I have in each sub-account and the value of them. A slight complication here: I need to know the breakdown across my cash, stocks and bonds, but my brokerage doesn’t explicitly show the breakdown between the values of stocks and bonds I own.

    I’ve therefore chosen to record whatever I see from my brokerage app under cash and position –where position is the sum of both stock and bond values — and then record my bonds’ value in a different row to separate them out from the stocks in the next calculations.

    I then calculate the percentage breakdown of my assets for the month. From this I get to see if I’m holding too much cash based on the 3-6 months of expenses recommendation or owning too many shares for my own risk appetite.

    The Rest

    Month-on-month savings shows how much value in each account changed from the current month to the last month.

    Untouchables describe the amount of money I have in my pension in Denmark. If I do choose to permanently leave Denmark before retirement age, I receive the money after paying taxes, hence the before and after tax rows. The last row describes the total amount of money that is mine (but also not really mine yet).

    Add-ons

    This file is the simplest version for how I keep an overview of all my money across different accounts and currencies. It’s a fairly simple exercise to add more rows if you have more accounts, and more columns if you deal with more currencies.

    In my own copy, I’ve also tried gamifying the process. I added quarterly goals at the start of each quarter and reminders for myself how much “work” needs to be done in the next months to hit my targets.

    Caveats

    I’ve seen other content creators deciding to exclude unrealised gains and losses as part of their tracking. That exercise however is too cumbersome and less meaningful to me, as I still use the month-on-month movements to decide how much or less to invest.

    I currently also have no debts, so I have not accounted for any.

    An even better overview?

    My process is still a highly manual one, and I would ideally love to have an app that can automatically tap into my bank accounts and give me a customised view of my assets. In fact, it sounds like Singapore already has one (OCBC OneView):

    And it sounds amazing, with overviews not just on net-worth based on cash and stock market positions, but also insurance policies, home loans, taxes…

    For the Singaporeans using the financial OneView, how is that going for you?

    Is there a Danish version?

    I’ve heard about the Panorama tool by Danske Bank, and it reads like it’s a financial advisory tool for them to recommend optimising asset allocation, loan structuring, future planning etc., more than a financial tracking tool just for keeping an overview.

    Thoughts if you’ve used it? 🧐

    In sum

    I’ve been tracking my finances, the process works for me, but it could be so much better. If you’re new to the process, feel free to use the Excel file shared above. If not, I’d love to hear what your process is and if there’s something I’m missing out on, especially in the Danish context, I’d love to hear your thoughts. 🤩

  • The Extra Cost in Dollar Cost Average Investing?

    The Extra Cost in Dollar Cost Average Investing?

    With some spare cash in my current account, I’ve started exploring investing in individual stocks and ETFs more seriously. To begin putting your money into these investments, most investors would have already heard of the lump-sum investing and dollar-cost averaging (DCA) strategies.

    What are they?

    As their names suggest, lump-sum investing simply means investing all your money into an asset at the same time, while DCA means investing smaller amounts of money at regular intervals, over a period of time.

    There are pros and cons to each approach, with a key difference being risk management. According to this Fidelity article:

    [DCA] potentially [helps] reduce the impact of volatility on the overall [asset] purchase. This can serve as a risk management trading strategy if you end up buying more when the price is relatively lower and buying less when the price is relatively higher.

    As I’m uninterested in timing the market (i.e. trying to outsmart other investors by speculating when to buy low and sell high — which in this case would make lump-sum investing a good strategy), DCA sounded like a great strategy as I minimise my transaction risks while I get exposure to the stock markets.

    Andrei Jikh (who’s currently my favourite finance Youtuber) talked about investing US$100 👏🏼every👏🏼day👏🏼 into the VTI and SCHD ETFs here.

    But what’s the catch?

    DCA has a big drawback, especially for retail investors who are looking to invest small amounts of money in regular intervals.

    You could be better off accumulating your money into bigger amounts before investing in longer intervals, e.g. investing $2000 every 2 months, instead of investing $1000 every month. If lump-sum investing and DCA are two ends of a spectrum, the optimal spot for a (risk-averse) investor is at neither ends, and where on the spectrum depends on your own risk appetite. DCA is not a catch-all for the risk-averse because of 💲transaction costs💲.

    When transaction costs come into play

    Depending on the broker you’re transacting your assets through, they have various kinds of fee models. For simplicity, I’m expressing transaction costs as a proportion of the monthly investment amount, so there is no need to consider fees separately (e.g. buying fees, management fees, currency conversion…).

    To visualise the impact of transaction costs, we’ll compare how a portfolio with no cost differs from those with costs. The graph below shows 4 portfolios:

    • Portfolio 1 (in black): The investor invests $5000 every month with no monthly transaction costs. Zero transactional cost will never hold true in reality, so this portfolio is just a hypothetical benchmark.
    • Portfolio 2 (in orange): The investor invests $5000 every month, but with 0.1% of investment value as transaction cost, which works out to be $5 every month.
    • Portfolio 3 (in green): $5000 investment every month, 1% transaction cost, which works out at $50 every month.
    • Portfolio 4 (in blue): $ 5000 investment every month, 10% transaction cost, which works out at $500 every month.
    Difference between portfolios is the percentage-point difference in transaction costs

    By the end of 6 years, Portfolio 1 (with no cost) ended at $360,000, Portfolio 2 (0.1% cost) ended at $359,960, Portfolio 3 (1% cost) ended at $356,400 and Portfolio 4 (10% cost) ended at $324,000.

    In percentages, Portfolio 2 has performed 0.1% worse than Portfolio 1, Portfolio 3 has performed 1% worse than Portfolio 1, and Portfolio 4 has performed 10% worse than Portfolio 1. (Perhaps) Surprisingly, the differences in portfolio performance are the same as the percentage-point differences between the transaction costs.

    In other words, your DCA strategy will perform x% worse than the best hypothetical DCA strategy, and x% is your transaction cost as a percentage of your investment amount at each interval.

    What if I include a principal and projected returns?

    The previous example assumed $0 initial investment and 0% growth in the money invested. The next graph shows the same portfolios, but with an initial $100,000 investment (also subjected to investment costs), and 6% annual growth in money invested.

    Difference between portfolios is still just the percentage-point differences in transaction costs

    The conclusion stays the same, where the differences in performance is simply the percentage-point differences between the transaction costs of the portfolios.

    Pay attention to your transaction costs

    Given that the key differentiator between DCA strategies is how low we can push the transaction costs as a percentage of the investment amount, it’s crucial to get the correct view of transaction costs each time we make a purchase.

    I can’t speak for all brokerage apps, but this is what I see when I try to buy an ETF through my bank:

    Transaction costs at first glance

    While it’s tempting to simply calculate my transaction cost here as 14/1815.8 * 100% = 0.771%, a more realistic amount is in fact 1.695%, and arriving at this number involved a few more clicks in the app.

    Transaction costs at second glance

    Another important implication of miscalculating your transaction cost is having a cost-to-investment ratio so high that the investment takes a long time to hit breakeven.

    In a nutshell

    Always consider your transaction cost as a percentage of your total transaction amount at each DCA interval.

    If we consider purely in absolute amounts, while a transaction cost of $5000 might raise alarm bells, we might start thinking that a transaction cost of $10 is acceptable or even cheap. This is not entirely true.

    If a stock costs $100 while you have to pay $10 in transactional cost, this translates to 10% of the investment amount. Consistently paying 10% in transaction costs means losing out substantially to other DCA strategies (which becomes a hefty amount when more money is involved) and the investment having to make 10% before turning a profit.

  • What Is Factor Investing?

    What Is Factor Investing?

    I’ve recently taken a class in CBS on factor investment strategies and I thought it’d be really cool to share some of the results I found while writing a paper. 😎

    I’ve always been interested in investing but I’ve never been a fan of buying stocks (or other investment vehicles) by word of mouth, because they’re trendy or simply based on gut-feel. I’d prefer to do my due diligence: conduct some form of independent research and ascertain the vehicle’s value before buying it.

    But alas, I have zero background in corporate finance, nor do I know how to conduct deep-dives into financial statements, and I don’t have time to regularly pore through companies’ annual reports before deciding what stocks or bonds I’d like to buy.

    So this is where I think factor investing offers a nifty solution.

    Factor Investing

    Very simply put, factor investing involves choosing securities (or just stocks) based on characteristics that are associated with higher returns. Common characteristics include size (buy small stocks), value (buy cheap stocks) and quality (buy good quality stocks).

    What???

    To illustrate, buying stocks based on the size characteristic simply involves calculating the market capitalisation of all companies in the market, then buying the stocks of say, the bottom 30% of companies based on this metric.

    On the other hand, buying stocks based on the quality characteristic could involve calculating the return on assets of all companies in the market, then buying the stocks of the top 30% of companies based on this metric.

    That’s it?

    There is in fact a multitude of characteristics and ways to proxy for these characteristics (briefly discussed here), but they are beyond the scope of this article.

    And how is this a “solution”?

    Choosing stocks based on their characteristics,

    1. satiates my need to conduct fundamental/ quantitative (albeit hasty) research before buying anything, and said research
    2. can be implemented easily over a large number of stocks, which
    3. implies that if I do execute my factor investment strategies, my portfolio is diversified.

    So how well do factor investment strategies perform?

    I’ve chosen to create portfolios of stocks based on the value, quality and size characteristics, and here’s a quick plot of their cumulative returns:

    Cumulative and annualised returns of all portfolios

    The graph above indicates that if you’ve invested $1 into the portfolios built from the value and quality characteristics in 2001, the $1 would have turned into $22.03 and $14.91 respectively in June 2021 🤩. These translate into annual returns of roughly 17.5% and 15.0% respectively. 🤩🤩

    The outcomes would have been markedly different if you had invested $1 into the benchmark portfolio, which is a naive strategy of simply buying every single stock there is in the market, or the portfolio built from the size characteristic.

    All portfolios seem to even be COVID-proof. 😱

    Dataset, the nitty-gritty, and some caveats

    Now that I’ve hopefully gotten your attention, these numbers come with several important notes.

    Dataset

    Related to the dataset:

    1. the graph above is derived from US stocks from January 2001 to June 2021,
    2. the stocks comprise of 15,823 companies that are both still active or have gone inactive, averaging 94 months of available data, and
    3. the dataset is obtained from the Wharton Research Data Services/ Compustat,

    while some important notes concerning my data processing steps are my choices to:

    1. limit return rates to the 99th-percentile return rates of all companies in each month, because some companies report extremely high (and unlikely) monthly returns on certain months and these high values distort my portfolio performances quite significantly,
    2. remove financial firms from the pool of these stocks, and
    3. keep micro-cap stocks in this pool of stocks even though they might introduce complexities such as poor fundamental data quality, with some literature also claiming that they bore little economic relevance.

    Building the portfolios

    Beginning with the simplest, the benchmark portfolio was constructed simply through buying all stocks available in the dataset. Companies can come and go throughout the 20-year horizon, so the basket of stocks that make up the benchmark portfolio can in fact comprise of different stocks month-on-month, over the years.

    The portfolio based on buying small stocks is built by:

    1. computing the market capitalisation for every company on a monthly basis,
    2. ranking all companies by their market capitalisation values, and
    3. buying the bottom 30% companies based on this metric.

    As the market capitalisation is calculated every month, the stocks that make up this “small-stocks” portfolio can therefore also change month-on-month.

    The portfolios based on buying value and quality stocks follow a similar logic, except value stocks involve buying top 30% companies by book-to-market ratios, and quality stocks involve buying top 30% companies by return on assets.

    Are the returns in fact any good?

    If it was so easy to construct these portfolios, where I simply have to buy stocks based on some easily calculated metrics, what’s stopping every other investor from doing the same and then eventually arbitraging away any excess returns that might be associated with these characteristics?

    Indeed, there are loads of literature debating if the size characteristic/ factor still remains, while many assert value and quality’s presence. Regardless, I compare all portfolios to the U.S. 4-week T-Bill rates — where the T-Bill is a relatively risk-free asset — to test if my actively managed portfolios are able to outperform an asset that requires relatively less investor involvement and entails lower risks.

    Cumulative and annualised returns of all portfolios, with risk-free asset

    As the line in red suggests, consistently investing in the T-Bill could yield similar to much better returns than just simple factor investing.

    In sum

    I’ve barely scratched the surface of factor investing, and there are in fact countless other nuances that could be considered. On top of various other characteristics/ factors, there are different ways to proxy for these characteristics, different ways of weighing the returns of each stock in every portfolio, and even the possibility of combining short-selling and going long on stocks, instead of the long-only portfolios that I have described.

    Nonetheless, I think this exercise was a pretty good prelude either to fundamental analysis, to fancier combinations of factor investing, or simply a reassurance that sometimes risk-free assets are the way to go for the uninitiated. 😅

  • Sentiment Analysis on Singaporean Twitter’s  Reactions related to COVID-19

    Sentiment Analysis on Singaporean Twitter’s Reactions related to COVID-19

    I recently became acquainted with the BSI Sentiment Analysis Pipeline created at BSI Bocconi (thanks Mathilde! 😉) and having failed before at scraping Twitter’s data, I decided to give this tool a shot. It turned out to be a gift that kept on giving.

    My initial idea was simply to download tweets from Twitter and store these tweets in a structured, tabular form. While it sounds straightforward, many tools currently are either outdated and do not work, require a Twitter developer account or necessitate other cumbersome steps. The BSI Sentiment Python library works after these 2 lines (in Anaconda Jupyter NB):

    !pip install bsi-sentiment --upgrade
    
    from bsi_sentiment.twitter import search_tweets_sn
    

    Their GitHub page shows an example of downloading tweets from Twitter, which I’ve modified into the following for a Singaporean context:

    tweets = search_tweets_sn(
      q="singapore",
      since="2020-01-01",
      until="2020-12-31",
      near="Singapore",
      radius="200km",
      lang="en",
      max_tweets=-1
    )
    
    tweets.get_sentiment(method="vader")
    tweets.to_csv("./results.csv")
    

    Following this chunk of codes, tweets made from (presumably public accounts) within 200km radius of Singapore, in year 2020, containing the word “singapore”, are downloaded and stored in a .csv file named “results” in my local drive. Not only that, any keen eye would have spotted the get_sentiment() method. This allowed me to also obtain a “sentiment score” for every downloaded tweet! Exciting! 🤩

    Sentiment Analysis

    In a brief two-liner, sentiment analysis in this context is simply assigning a score to a tweet based on its content. Depending on the score assigned, the sentiment of the tweet is then assessed on a range of negative (<=-0.05) to neutral (-0.05 to 0.05) to positive (>=0.05). The scoring algorithm is based on VADER, “a lexicon and rule-based sentiment analysis tool that is specifically attuned to sentiments expressed in social media“. More details available here.

    Chinese New Year Tweets

    Since I’m now able to easily obtain sentiment scores to every tweet that I’ve downloaded, it quickly occurred to me to try comparing sentiments surrounding CNY over the years, and especially in 2020 and 2021 as CNY 2020 in Singapore happened when the COVID-19 pandemic was first picking up, while CNY 2021 happened with some restrictions imposed by the Singaporean government. Here’s some visualisation:

    Sentiments surrounding CNY, 6 months before and 14 days after

    Each dot represents a tweet, a dot with “polarity” below or equals -0.05 is interpreted as a negative tweet, between -0.05 to 0.05 as a neutral tweet and above or equal to 0.05 as a positive tweet. High intensity in colour is due to the dots overlapping, indicating high tweet frequency during that time.

    It’s quickly apparent that tweets about CNY are generally made about a month before CNY, peaking in frequency around CNY itself (when “Day from CNY” = 0) and are generally neutral to positive, seemingly regardless of the COVID-19 pandemic. The spread in polarity seems similar across all years. There are notably fewer positive tweets in 2021 (indicated by the lower intensity in colour) but it’s probably attributable to lower tweet counts in general and not a shift from positive to neutral or negative sentiments.

    Circuit Breaker

    I wanted to investigate the scoring methodology a little further so I decided to see what people were saying about the circuit breaker measure Singapore had implemented back in April 2020.

    Sentiments surrounding circuit breaker

    In brief, strict restrictions (termed collectively as the circuit breaker (CB)) were announced on 3rd April (first red line), enacted on 7th April (second red line) and announced to extend on 21st April (third red line).

    Expectedly, many tweets containing the terms “circuit breaker” started to show up after the first CB announcement and lasted until some time after the announcement of its extension. What was curious to me however, was the high amount of positive tweets relative to negative ones regarding the CB, even after its extension. I did not expect Singaporeans to tweet favourably about such a measure, and even less so after it got extended.

    Perhaps the VADER model doesn’t understand the Singaporean context?

    As the positive sentiments didn’t make immediate sense to me, I created a word cloud to explore some of the most common words in these CB-related tweets.

    Common words in CB-related tweets

    The size of each word represents the frequency of it appearing in the CB-related tweets. This word cloud seems to lend a bit more credence to the positive sentiments picked up earlier, with frequent words including, “love”, “thank”, “good” and “happy”. There is nothing jarringly negative except perhaps “lockdown”, though I’m not entirely sure how the VADER model would rate this word.

    In sum

    I got disproportionately excited about the BSI Sentiment Python library, one idea led to another and culminated in this very insightful exercise. Kudos to the BSI Bocconi team for putting this library together and I hope it remains functional for a long time to come! Please also feel free to comment if you spot any mistakes or have other interesting views to share. (Apparently it also pays to be a busybody on LinkedIn — please keep sharing or liking useful tools on there! 😉)

  • How To Learn Python Effectively

    How To Learn Python Effectively

    Python is third in programming language popularity and people are (literally) buying in.

    TIOBE data from tiobeindexpy; visualisation codes from here

    On the data science front, Coursera’s lists of Top 10 Courses in 2020 and 2019 include:

    1. Machine Learning by Stanford University
    2. Programming for Everybody by University of Michigan
    3. AI For Everyone by DeepLearning.AI
    4. Algorithms by Princeton University
    5. What is Data Science by IBM, and the list goes on…

    I get it — data science, analytics, machine learning, AI… they all sound really kewl, trendy 😎 and because they’re so heavily thrown around as buzzwords, we become curious and want a slice of the analytics pie. People around me have spoken about picking up Python, Tableau, SQL… and if you find yourself on the brink of “jumping onto the Python bandwagon” or wanting to give programming a shot, here’s a good way to get started with analytics.

    Start with well–received course materials

    A natural first step to begin learning anything is to sign up for a Coursera or an edX course. This is easy — you can either get acquainted with this free MIT open courseware on the Introduction to Computer Science and Programming or sign yourself up on Coursera for a well-reviewed course. I audited (the famous) CS1010S during my time in NUS.

    While this is a great start, it gets increasingly difficult to follow through because your initial curiosity that prompted you to sign up for the course quickly gets extinguished by the rigour of the course content. You might find yourself zoning out, procrastinating and ultimately failing to complete the course. This happened to me when I attempted a financial engineering course on Coursera, and it brings me to the importance of a parallel point.

    Envision an easy and appreciable purpose

    Setting a goal for yourself to achieve using Python or another analytics tool is imperative and a good way to keep you focused and motivated as you’ll be aware of your own learning outcomes. In fact, with one, or even a series of clear, achievable purpose(s), you will realise that the course content does not immediately help you achieve your purposes, and you will have to google the rest. But what you find on Google is now a lot more understandable as you’ve progressed through your course materials, and you end up mastering more than what you had signed up for. Here’s what I mean:

    Deciding a purpose

    Your goal or purpose could be something as ambitious as applying text analytics on your personal credit card statements, generating stereograms, or just for starters, to simply generate the TIOBE index chart above. While it sounds innocuous and straightforward, here’s the source code to generate it:

    !pip install tiobeindexpy
    
    from tiobeindexpy import tiobeindexpy as tbpy
    import seaborn as sns
    import matplotlib.pyplot as plt
    
    sns.set(style = "whitegrid")
    sns.set(rc={'figure.figsize':(11.7,8.27)})
    
    top_20 = tbpy.top_20()
    top_20['Ratings'] = \
    top_20.loc[:,'Ratings'].apply(lambda x: float(x.strip("%")))
    top_20['Change.1'] = \
    top_20.loc[:,'Change.1'].apply(lambda x: float(x.strip("%")))
    
    labels = top_20['Programming Language']
    values = top_20['Ratings']
    rank = top_20['Feb 2021']
    
    clrs = \
    ['tab:orange' if (x == 3) else 'tab:blue' for x in rank]
    sns.barplot(x=values, y=labels, palette=clrs)\
    .set_title('TIOBE Index \n\n Programming Popularity (Feb 2021)')
    
    plt.savefig('Programming Popularity.png', bbox_inches = 'tight')
    

    Evidently, this “simple” purpose of generating a bar chart in fact necessitates your mastery of Python’s syntax, data types, understanding how to import packages, manipulate dataframes, use anonymous functions and list comprehension. This is no mean feat, but precisely because you have a purpose/ end-goal in mind where you can visualise a working example to apply these concepts, hearing or learning about them as you progress through your course should feel more exciting and less abstract.

    You’ll also realise that while your course might cover content at the conceptual level, you’ll have to google how to change the colour for a specific bar in your bar chart, how to use 2 lines for your chart header or how to change the font size of your chart labels. In this manner, your purpose will prompt you to search beyond course materials and you’ll end up learning more.

    In sum

    While it might be tempting to jump on the bandwagon for a programming trend that comes along, it’s more important to ask yourself first if you’re fundamentally interested and if there’s any real use for what you’re jumping onto. If you are and there is, then identify one or a few purposes and work towards them while you complete your course material.

  • A Lazy Man’s Guide to Start Writing in LaTeX

    A Lazy Man’s Guide to Start Writing in LaTeX

    Skip introduction and jump to guide

    I’ve always loved the style of a LaTeX document since my undergraduate days but I’d never really gotten the chance to learn writing one, until couple of years ago when I worked in academia.

    Document written in LaTeX — accuracy of the equations not guaranteed

    I’ve never been a fan of clicking around graphical user-interfaces (GUI). My ideal approach had always been just to figure out the syntax of a programming language, write what I’d like to see from the program in some console, hit “Run” and see my output. Fumbling around with text styles, sizes, paragraphing, page and margin formatting, references etc. by clicking GUI icons, manual adjustments or using convoluted shortcuts felt like huge inconveniences and distractions to me.

    This has been all of us

    ***Then I discovered LaTeX***

    LaTeX provides the best kind of UI for me: I specify what I need as codes and it returns what I told it to do — FUSS FREE! (Well somewhat.) It also helps a lot that the default LaTeX font is gorgeous and looks very professional. Despite an initial learning curve, I’ve never looked back since. I’ve written my assignments and resume all in LaTeX now.

    Because I wished I had something “beginner-friendly” to reference when I started, here’s my attempt at a guide for anyone who wishes to start writing in LaTeX. I’m pitching this at the absolute layman so it will be extremely basic. I’ll either update with a follow-up (depending on my own competences) or you can Google the rest 🙂

    Step 1: Downloading LaTeX

    Go to The Latex Project to download the suitable distribution for your OS. I downloaded the MacTex distribution for my MacBook and MiKTeX on my Windows. I’m working primarily from my MacBook so I’ll continue with views from the MacOS and TeXShop. (TeXShop is the GUI program that comes with MacTex.)

    The process of writing a LaTeX document is the same regardless of OS, at least from I’ve encountered so far.

    Step 2: Getting Started

    Once you’re followed through with everything in the installation guide, search for “TeXShop” in your Spotlight (“command” + space) and hit “return”. Open MiKTeX if you’re using Windows.

    You should see this:

    All your codes go here

    This, and anything you write here will save as a .tex file.

    Create a folder on your desktop dedicated for this LaTeX document that you are going to write. You can name this folder whatever you like, but ideally with the same name as your .tex file.

    Before writing anything in this .tex file, save it (“command” + “S”) in the dedicated folder you’ve just created.

    Step 3: Start Writing

    You will always have to specify in the beginning of your .tex file the class of document you intend to write. I’ve only used “article” so far, but you could use “beamer” for presentation slides as well for example. Running or typesetting (button at the top-left corner or simply “command” + “T”) the following,

    \documentclass{article}
    
    \begin{document}
    
    Hey there, typesetting this will produce your first \LaTeX document. Enjoy!
    
    \end{document}

    will produce this:

    And you’re essentially done!

    There will be a bunch of seemingly random files produced in your dedicated folder after you’ve typeset your .tex file. I have — in all honesty — no clue about what those are, but leave them there and all you have to deal with are your .tex files and your output .pdf files. 🙂

    Step 4: Slightly More Complexities

    Everything you write before \begin{document} is called the preamble, while your content lies between \begin{document} and \end{document}.

    \documentclass{article}
    
    [your preamble]
    
    \begin{document}
    
    [your content]
    
    \end{document}

    In order to do certain things (like writing in mathematical notations), you will use packages. Some packages that I’ve used are amsmath and enumitem. You will insert them in the preamble like so:

    \documentclass{article}
    \usepackage{amsmath} %to write in math
    \usepackage{enumitem} %to produce a numbered list
    
    \begin{document}
    
    % everything behind % will be ignored during typesetting
    
    Hey there, typesetting this will produce your first \LaTeX document. Enjoy!
    
    Your mathematical equation: $E = mc^2$
    
    And you produce a numbered list here:
    
    \begin{enumerate}
    	\item point number 1,
    	\item point number 2
    \end{enumerate}
    
    \end{document}

    This produces:

    Evidently, more has to be done before this becomes a presentable document. This is the initial learning curve associated with LaTeX, but with enough use (and Googling), you can typically use the same “base template” for all your documents in the future.

    Check these links out for further guides:
    Paragraphing
    Writing in math
    Importing images into your document

    Opinion

    The main advantages for me from LaTeX are the minimal need to deal with GUI’s and the flexibility and convenience it accords with using codes.

    I’ve once had to repeatedly compile large volumes of images (every image changes with time), and each time in a similar format. This would have been a disaster if I were doing the formatting manually in Microsoft Word each time I get a new set of images. With LaTeX, all I had to do was write the base .tex file and specify the paths to each image once. I simply hit “Typeset” each time I get a new set of images and the output .pdf document gets updated with the new images in the same structure — no need to fuss with manual alignment and formatting. 🙂

    Separately, LaTeX is also great for bibliography management and referencing, but this will be a whole entry altogether, if anyone is interested.

    Lastly, my difficulties with LaTeX are usually solved with some Googling and copy-pasting codes from users who have posted their solutions. 😉

    Please feel free to reach out in the comment box below with further questions or point out any inaccuracies that you might find!