How do I solve text too wide error in LaTeX? - latex

The text is too long and will random break my first word over the entire first line...I don't know how to make it look like the other with short text. This is my code:
\documentclass[letterpaper,11pt]{article}
\usepackage{simplecv}
\begin{document}
\vspace{1em}
\entrybig
{\textbf{LexBox}}{Nov 2020 - Present}
LexBox represents the fastest and the most efficient way to make a contravention complaint without to get in touch with a lawyer.
\\\textbf{Technologies:} C\#, ASP.NET, jQuery AJAX, CSS \& HTML
\entrybig
{\textbf{GAM - Group Activity Manager}}{Oct 2020 - Present}
{This application is designed to remote control multiple desktops at the same time. \\
\textbf{Technologies:} C\#, .NET Framework}
\end{document}
and the .sty file is this
and the result is
this

Three major problems:
you must not use \entrybig on its own, it need to be inside a list, e.g. \outerlist{}
The syntax you use for \entrybig is wrong. This macro takes 4 mandatory arguments, not 2, not 3, exactly 4
as this macro gets inserted into table cells, you must not abuse \\ for line breaks
\documentclass[letterpaper,11pt]{article}
% Choose bibliography style for formatting list of publications
\usepackage[style=ieee,url=false,doi=false,maxbibnames=99,sorting=ydnt,dashed=false]{biblatex}
\bibliography{papers}
% Choose theme, e.g. black, RedViolet, ForestGreen, MidnightBlue
\def\theme{MidnightBlue}
\usepackage{simplecv}
\begin{document}
See more of my projects on \website{https://github.com/Mihutzen}
\vspace{1em}
\outerlist{
\entrybig
{\textbf{ETH Zurich}}
{Zurich, CH}
{M.S. in Computer Science, GPA: 5.63/6.00}
{2018\textendash 2020}
}
\end{document}

Related

Is there any way to automatically move periods inside quotation marks? (csquotes doesn't seem to work)

csquotes doesn't work in this case, maybe because I'm using a custom command:
\documentclass[12pt, letter, american]{article}
\usepackage[american]{babel}
\usepackage[autopunct,style=american]{csquotes}
\newcommand{\qq}[1]{\textquote{#1}}
\begin{document}
This is an \qq{example}.
\end{document}
\qq will not move the trailing period into the quotation, e.g. This is an \qq{example}. will still yield This is an “example”. I have written a book using \qq and would like to change the quotation styles to one which moves periods and colons into the quotes. Is there a safe way to achieve this automatically? Maybe a package different from csquotes? The only solution I've found on the net so far didn't work with spacing correctly.
See the csquotes documentation, section 9.2:
\documentclass[12pt]{article}
\usepackage[american]{babel}
\usepackage[autopunct,style=american]{csquotes}
\renewcommand{\mktextquote}[6]{#1#2#4#5#3#6}
\newcommand{\qq}[1]{\textquote{#1}}
\begin{document}
This is an \qq{example}.
\end{document}

How to automatic break lines in latex?

I have searched but nothing useless, only "use \newline" or "use \".
I'm creating a simple latex document to store any texts instead of using .txt, and the problem is that the pdf document contains the lines going towards right until they go out of the paper.
I'm using this simple code
\documentclass[a4paper]{article}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=5mm,
top=20mm,
}
\begin{document}
\section{Text 1}
Loremipsumdolorsitamet,consecteturadipiscingelit,seddoeiusmodtemporincididuntutlabore etdoloremagnaaliqua.Utenimadminimveniam,quisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequat.Duisauteiruredolorinreprehenderitinvoluptatevelitessecillum doloreeufugiatnullapariatur.Excepteursintoccaecatcupidatatnonproident,suntinculpaquiofficiadeseruntmollitanimidestlaborum.
\end{document}
Since latex sees it as a one word, it refuses to break it since it doenst know its hyphenation. But I would like to allow latex to break it regardless. Any thoughts ?
Remarks: I already have used:
\hspace{0pt}
\leavevmode\nobreak\hspace{0pt}
\mbox{Loremip...larorum.}
Nothing worked.
I think I got why nothing worked. See my code below, that I managed to compile successfully after editing your MWE.
You basically have two ways to force hyphenation here.
As in the comment by SamCarter, you manually split words within text, just using \- where necessary. I did it below in line 18 (6 from bottom).
You add to your preamble the command \hyphenation{word-to-split}: I did this below to hyphenate the word in line 20 (4 from bottom). Notice that, in this case, you use - instead of \- within the braces {} enclosing the argument.
\documentclass[a4paper]{article}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=5mm,
top=20mm,
}
\hyphenation{Duisauteiruredolorinre-prehenderitinvoluptatevelitesse-cillum doloreeufugiatnullapariatur}
\begin{document}
\section{Text 1}
Loremipsumdolorsitamet, consecteturadipiscingelit,
seddoeiusmodtemporincididuntutlaboreetdoloremagna.
Uten\-imadminimveniam,
quisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequat.
Duisauteiruredolorinreprehenderitinvoluptatevelitessecillumdoloreeufugiatnullapariatur.
Excepteursintoccaecatcupidatatnonproident,
suntinculpaquiofficiadeseruntmollitanimidestlaborum.
\end{document}
Finally, if the full stop character . is not followed by a space, two separate words may be interpreted as one and the command \hyphenation may not work as expected. Not sure that this was the detail making you write that nothing worked, but be careful to this too.

Referencing lines in email text

I'm trying to use Latex for a purpose it's probably not quite designed for and unsurprisingly having some difficulty. I'm attempting to include text from a series of emails, and then I want to write a summary that refers to line numbers within the emails, drawing attention to certain portions of a conversation.
For line numbering, I've found the lineno package works well and allows me to set up my reference targets with \linelabel{label1} macros, which can then be referenced with \ref{label1}.
However, as email chains in text format have many characters that need escaped such as > characters, I've been looking for a package that will allow me to treat the text as preformatted text while also still parsing the \linelabel Latex macro.
I've tried the verbatim environment and the lstlisting environment, but both appear to ignore the \linelabel macro. Is anyone aware of a package that does what I'm looking for?
Thanks in advance!
Edit: Added MWE. Runs in overleaf. Demonstrates that with lineno package I can successfully get line numbers to be output and they can be referenced when labels are defined in email content, but there are many characters that would need to be escaped. Also shows putting the email content within a lstlisting block, which formats the email more nicely but loses the linelabel macro parsing. Looking for a happy medium.
\documentclass[12pt,stdletter,orderfromtodate,sigleft]{newlfm}
\usepackage{listings}
\lstset{basicstyle=\footnotesize,stringstyle=\footnotesize,language=,}
\usepackage{lineno}
\begin{document}
\section{Summary}
Refer to line \ref{label1}. And then he did it again on line \ref{label2}.
\newpage
\linenumbers
\section{Emails with no formatting}
Email response number 2
On Wed, Sep 9, 2020, 9:15 AM Anonymous wrote:
> Hi Umptyscrunch,
>
> I'm letting you know that I did that thing.
>
> Thanks,
> Marklar
>
Hi Marklar,
\linelabel{label1} Yeahhh. I'm going to need you to come in this Saturday.
Thanks,
Umptyscrunch
---------- Forwarded message ---------
No rush, it's all good my friend. It's a minimal working example.
\section{Emails with listing formatting}
\begin{lstlisting}
Email response number 2
On Wed, Sep 9, 2020, 9:15 AM Anonymous wrote:
> Hi Umptyscrunch,
>
> I'm letting you know that I did that thing.
>
> Thanks,
> Marklar
>
Hi Marklar,
\linelabel{label2} Yeahhh. I'm going to need you to come in this Saturday.
Thanks,
Umptyscrunch
---------- Forwarded message ---------
No rush, it's all good my friend. It's a minimal working example.
\end{lstlisting}
\end{document}
I would use the listings package. It can show line numbers, reference specific lines and you can even colour replies:
\documentclass[12pt,stdletter,orderfromtodate,sigleft]{newlfm}
\usepackage{listings}
\lstset{
basicstyle=\footnotesize\ttfamily,
stringstyle=\footnotesize,
escapeinside={&}{&},
numbers=left,
morecomment=[l][\color{blue!80}]{> },
morecomment=[l][\color{red!80}]{>> },
}
\begin{document}
\section{Summary}
Refer to line \ref{label2}.
\begin{lstlisting}
Email response number 2
On Wed, Sep 9, 2020, 9:15 AM Anonymous wrote:
> Hi Umptyscrunch,
>
> I'm letting you know that I did that thing.
>
>> previous reply
>
> Thanks,
> Marklar
>
Hi Marklar,
&\label{label2}&Yeahhh. I'm going to need you to come in this Saturday.
Thanks,
Umptyscrunch
---------- Forwarded message ---------
No rush, it's all good my friend. It's a minimal working example.
\end{lstlisting}
\end{document}
(replace the & for the escape char with any letter or letter sequence that won't occur in your emails)
Here's something I'm moderately happy with. Although I don't want to have to insert the newline \\ characters at the end of each line. I'd rather it be like the verbatim package which treats newlines in the input as line breaks in the output. Switching to courier font resolves problems with the > characters showing up as ? in the output.
\documentclass[12pt,stdletter,orderfromtodate,sigleft]{newlfm}
\renewenvironment{email}{\fontfamily{pcr}\selectfont\begin{footnotesize}}{\end{footnotesize}\par}
\renewcommand{\L}{\linelabel}
\usepackage{lineno}
\begin{document}
\section{Summary}
Refer to line \ref{label1}. And then he did it again on line \ref{label2}.
\newpage
\linenumbers
\section{Emails with no formatting}
\begin{email}
Email response number 2\\
\\
On Wed, Sep 9, 2020, 9:15 AM Anonymous wrote:\\
\\
> Hi Umptyscrunch,\\
>\\
> I'm letting you know that I did that thing.\\
>\\
> Thanks,\\
> Marklar\\
>
\\
Hi Marklar,
\\
\L{label1}Yeahhh. I'm going to need you to come in this Saturday. This line is so long it should wrap. I believe you have my stapler. \\
\\
Thanks,\\
Umptyscrunch
---------- Forwarded message ---------
No rush, it's all good my friend. \linelabel{label2}It's a minimal working example.
\end{email}
\end{document}

Conditionally execute a macro depending on the font used

I’m a big fan of ampersands – so much that I heed SimpleBits’ advice to “use the best available ampersand” quite religiously.
For that purpose, I’ve defined the following shortcut in LaTeX:
\let\amp\&
\renewcommand\&{{\scalebox{1.2}{\textnormal{\fontspec{Baskerville}\itshape\amp}}}}
In brief, this changes all uses of the “normal” ampersand to a stylish variant, e.g.:
This is a text \& it contains an ampersand.
(Using \& instead of just & since that’s how LaTeX works – the latter is already reserved to separate columns in table environments.)
However, this always uses the same font – here, Baskerville – no matter whether it fits or not. I’d like to use a different font depending on the font family used. That is, I want to use another ampersand in combination with sans serif text, and in particular I want to prevent rewriting of the ampersand in a monospace context. So in the following two contexts, I don’t want to trigger the above definition:
{\sffamily a \& b}
{\ttfamily a \& b}
How do I do that?
I imagine something like the following:
\renewcommand\&{
\ifsans
{\fontspec{Trebuchet MS}{\textnormal{\itshape\amp}}}
\else
\ifmono
\amp
\else
{\fontspec{Baskerville}\scalebox{1.2}{\textnormal{\itshape\amp}}}
\fi
\fi}
It works the following way:
\documentclass[letterpaper,10pt]{article}
\usepackage[latin1]{inputenc}
\usepackage{german}
\usepackage{geometry}
\geometry{margin=2cm}
\newcommand*\origsffamily{}
\let\origsffamily\sffamily
\renewcommand*\sffamily{\origsffamily\small {\renewcommand\&{{\scalebox{1.2}{\textnormal{\fontspec{Baskerville}\itshape\amp}}}}}}
\begin{document}
hello, this is \& a \sffamily test \&
\end{document}
That means, you include the change of the ampersand sign into the definition of (in my example) \sffamily.
The drawback is - of course - that you have to do this for all desired font families.
You can test for the standard LaTeX token list \f#family, however, this might not be as reliable as you want. The following code simply checks whether the current family equals the default families set by \setmainfont and \setsansfont, but not whether the fonts are really sans-serif:
\documentclass{article}
\usepackage{fontspec}
\usepackage{expl3}
\usepackage{xparse}
\setmainfont{DejaVu Serif}
\setsansfont{DejaVu Sans}
\makeatletter
\ExplSyntaxOn
\NewDocumentCommand \amp { } {
\tl_if_eq:NNTF \f#family \rmdefault {
% this is a roman font
A
} {
\tl_if_eq:NNTF \f#family \sfdefault {
% this is a sans font
B
} {
% something else
C
}
}
}
\ExplSyntaxOff
\makeatother
\begin{document}
test \amp\ test
\sffamily
test \amp\ test
\ttfamily
test \amp\ test
\end{document}

How does one change the \paragraph formatting in LaTeX

This stems out of How can one number paragraphs in LaTeX?, which I asked earlier today:
Running with Brent.Longborough's suggestion for how to number paragraphs in a document:
\setcounter{secnumdepth}{5}
...
\paragraph{If we want to}
\paragraph{do something}
This results in LaTeX producing something likeso:
0.0.0.1 If we want to
0.0.0.2 do something
How can one change the numbering scheme of \paragraph{} to produce something like:
1. If we want to
2. do something
or alternatively
A. If we want to
B. do something
Thank you.
To change the number referenced when referring to paragraphs, you want to change \theparagraph. Here's an example:
\documentclass[12pt]{article}
\setcounter{secnumdepth}{5}
\renewcommand\theparagraph{\roman{paragraph}}
\usepackage{lipsum}
\begin{document}
\paragraph{foo} \lipsum[1]
\paragraph{bar} \lipsum[2]
\end{document}
Instead of \roman you can also use \Roman, \arabic, \alph, \Alph. Although if you have lots of paragraphs you'll want to use the alphalph package and use \alphalph to get more than 26 paragraphs.
Note that \paragraph takes an argument for the "paragraph title". If you never want that, you'll probably want to define your own command to simplify things:
\newcommand\PARA{\paragraph{}}
You'll also probably want to remove the way that paragraphs are numbered "within" sections; i.e., they reset from "1" for every new section. You can get around this with something like
\usepackage{remreset}
\makeatletter
\#removefromreset{paragraph}{section}
\makeatother

Resources