TransWikia.com

How to align text vertically with fixed textwidth?

TeX - LaTeX Asked by herophant on February 19, 2021

I’m lost on how to align text properly. Anything I search up with respect to textwidth only gives results on how formatting tables work, but I’m just trying to work with plain text here. Any idea what I’m getting wrong? I’m trying to work on a resume and was using a XeLaTeX example that I found online. Any help appreciated.

PS. I have 0 experience with LaTeX and everyone says you have to learn by doing, so I guess I’m doing.

documentclass[a4paper]{article}

usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{textcomp}
usepackage[dutch]{babel}
usepackage{amsmath, amssymb}


% figure support
usepackage{import}
usepackage{xifthen}
pdfminorversion=7
usepackage{pdfpages}
usepackage{transparent}
newcommand{incfig}[1]{%
    defsvgwidth{columnwidth}
    import{./figures/}{#1.pdf_tex}
}

newcommand*{entryskillstyle}[1]{{{textwidth #1 50cm}fontsize{15pt}{1em}bodyfontbfseriescolor{black} #1}}
pdfsuppresswarningpagegroup=1

begin{document}
setlength{entryskillstyle}{9cm}
entryskillstyle{Hello TeX world}
entryskillstyle{Hello StackExchange world}
end{document}

This is what I want it to look like with respect to alignment (excluding formatting) (it’s maybe not clear in this example, but I want only "Hello TeX World" and "Hello StackExchange world" to be aligned, I don’t care about the rest of the text):

Hello TeX World              I'm eating a salad
Hello StackExchange world    I'm eating a veggie burger

What I’m actually getting:

enter image description here

One Answer

enter image description here

documentclass[a4paper]{article}

begin{document}

noindent
begin{tabular}{@{}ll@{}}
Hello TeX world& I'm eatingldots
Hello StackExchange world& I'm eating
end{tabular}
end{document}

If you get errors (your posted code gives undefined command errors) then the generated PDF is not intended to be useful. TeX only recovers from errors enough to debug the document it does not make any real attempt to make a sensible typeset output.

It is much easier to start from a simple document and only add packages if you need them. Most of the packages you are loading do not seem relevant and if you are using xelatex then you should never load inputenc or fontenc.

Correct answer by David Carlisle on February 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP