I am using this resume template to create my resume: https://github.com/posquit0/Awesome-CV.
I am completely new to latex. Currently, when I use cvitems:
%Define an environment for cvitems(for cventry)
\newenvironment{cvitems}{
\vspace{-4mm}
\begin{justify}
\begin{itemize}[leftmargin=2ex, nosep, noitemsep]
\setlength{\parskip}{0pt}
\renewcommand{\labelitemi}{\bullet}
}{
\end{itemize}
\end{justify}
\vspace{-2mm}
}
All the items are listed as follow:
item A
item B
What modifications to the above code can I make so that the list can look like this (item A and item B are on the same row)?
item A * item B
Here is how I use cvitems in the tex file:
{\begin{cvitems}
\item {item A}
\item {item B}
\end{cvitems}}
I would define a special command for two-item items as follows
\newcommand\twoitems[2]{%
\item#1%
\hspace{10pt}%
\labelitemi
\hspace{\labelsep}#2
}
Notice I used 10pt as spacing between items, you could use a different one.
Here is an MWE that applies the idea. In this example, I keep the cvitmems as in your MWE, though in truth it is really not doing anything, that is, you could as well use the standard itemize environment.
\documentclass{article}
\begin{document}
\newcommand\twoitems[2]{%
\item#1%
\hspace{10pt}%
\labelitemi
\hspace{\labelsep}#2
}
\newenvironment{cvitems}%
{
\begin{itemize}
}%
{
\end{itemize}
}
\begin{cvitems}
\item A
\item B
\twoitems{A}{B}
\end{cvitems}
\end{document}
Here's the output: https://i.stack.imgur.com/BZvt0.png
Related
In latex, I need to start an item in an enumerate list with an align* environment, but this environment starts with a new line, leaving an ugly empty space.
What I'm trying to achieve:
e^{ix}=cos x+i sin x
e^{i\pi} = -1
e^{i\pi}+1=0
What I'm trying:
\begin{enumerate}
\item \begin{align*}
e^{ix}&=\cos x+i\sin x\\
e^{i\pi}&=-1\\
e^{i\pi}+1&=0
\end{align*}
\end{enumerate}
Is there some other environment for this?
(I know that it is not recommended to start an item with a displayed math formula, but in this case I need to.)
As a workaround:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{enumerate}
\item \hfill$\begin{aligned}[t]
e^{ix}&=\cos x+i\sin x\\
e^{i\pi}&=-1\\
e^{i\pi}+1&=0
\end{aligned}$\hfill\mbox{}
\end{enumerate}
\end{document}
A hack similar to the one in the accepted answer: the environment matrix needs no package to work and has no visible delimiters:
\documentclass{article}
\begin{document}
\begin{enumerate}
\item $\begin{matrix}
e^{ix}&=\cos x+i\sin x\\
e^{i\pi}&=-1\\
e^{i\pi}+1&=0
\end{matrix}$
\end{enumerate}
\end{document}
The output seems to me similar to the one you wanted to achieve:
I'm using enumitem to enumerate my variables list.
I have a variable list like:
\begin{enumerate}
\item My First Cool Variable \label{var:myvar1}
\item My Second not so Cool Variable \label{var:myvar2}
\item My Third so so \label{var:myvar3}
\end{enumerate}
When I cross-reference one of these items, I get the list key. For example,
Let us reference \ref{var:myvar2} and then my other variable \ref{var:myvar3}
Gives:
Let us reference 2 and then my other variable 3
What I'd like is to not only be able to obtain the list key, but also the whole item text, so the output could be like:
Let us reference My Second not so Cool Variable and then my other variable My Third so so
The goal is to be able to write the variable name only once, and not changing everywhere if ever the variable name is modified to something more specific.
Any ideas? I've taken a look into enumitem-zref but I couldn't find what I was looking for :/
Using some ideas from Macro to capture until end-of-line as argument, you can capture the contents following an \item:
\documentclass{article}
\usepackage{environ}
% https://tex.stackexchange.com/q/127005/5764
\makeatletter
\NewEnviron{wordenumerate}{%
\begin{enumerate}
\let\olditem\item
\def\item##1\item{\dosomething{##1}}%
\expandafter\#empty\BODY\item
\end{enumerate}%
}
\let\oldlabel\label
\newcommand{\dosomething}[1]{%
\def\elvitaluz#arg{#1}%
\ifx\elvitaluz#arg\elvitaluz#stop
\end{enumerate}
\expandafter\env#ignore % to end the recursion
\else
\def\label##1{\def\#textlabel{##1}\let\label\relax}% Capture \label
\olditem #1
\ifx\label\relax
\def\label##1{\#bsphack\#esphack}%
\edef\#currentlabel{#1}% % what to do with #1
\expandafter\oldlabel\expandafter{\#textlabel}%
\fi
\expandafter\item % to continue the recursion
\fi}
\edef\elvitaluz#stop{\noexpand\end{enumerate}\noexpand\env#ignore\space}
\makeatother
\begin{document}
\begin{wordenumerate}
\item First
\item Second\label{second}
\item \label{third}Last
\end{wordenumerate}
Item~2 is \ref{second}. Item~3 is \ref{third}.
\end{document}
The use of a new environment wordenumerate is suggested, as an entirely different \label-\ref is at play. I would not suggest nesting this environment in anything else (also because of the use of environ).
I want to produce the following in LaTeX:
1. Item
2. Item
3a. Item
3b. Item
4. Item
5. Item
Basically I have already tried using nested enumerate environments, but I have a problem with implementing the different numberings.
How can I do the above in LaTeX?
The purpose of the {enumerate} environment is to number things algorithmically. If you really want the numbers to appear as shown in your question, I can't identify what algorithm you want to be used. For the example you show, I think the easiest method is just to program the labels yourself instead of trying to program LaTeX to do it. I would just do it this way:
\begin{itemize}
\item[1.] Item
\begin{itemize}
\item[2. ] Item
\item[3a. ] Item
\item[3b. ] Item
\item[4. ] Item
\end{itemize}
\item [5. ] Item
\end{itemize}
With LaTeX, the quickest path to a solution often involves brute force :-)
Quick and dirty:
\documentclass{article}
\begin{document}
\renewcommand{\labelenumii}{\addtocounter{enumi}{1}\arabic{enumi}}
%% Second list uses first counter
\def\startenumtuple{\setcounter{enumii}{1}\addtocounter{enumi}{1}
\renewcommand{\labelenumii}{\arabic{enumi}.\alph{enumii}}}
\def\endenumtuple{
\renewcommand{\labelenumii}{\addtocounter{enumi}{1}\arabic{enumi}}}
\noindent Here's my list:
\begin{enumerate}
\item Item
\begin{enumerate}
\item Item
\startenumtuple
\item Item
\item Item
\endenumtuple
\item Item
\item Item
\end{enumerate}
\item Item
\end{enumerate}
\end{document}
(Mica's version was used in the first iteration of this code)
The right way involves defining environments based on enumerate that do the right thing with the counters: the above code would need tweaking to get it to work right if you wanted to change the nesting of the list environments.
\renewcommand{\labelenumi}{\Roman{enumi}.}
\renewcommand{\labelenumii}{\Roman{enumi}. \alph{enumii}}
\noindent Here's my list:
\begin{enumerate}
\item Item 1.
\begin{enumerate}
\item List 2, Item 1
\item List 2, Item 2
\end{enumerate}
\item Item 2.
\item Item 3.
\end{enumerate}
Then change the \Roman in the renewcommand to whatever you want it to be: \alph or \arabic
I want to produce output something like this:
1. List item
2. Another list item
Paragraph of comments on list items 1 and 2.
3. Further item
4. Final item
I'm sure I've seen a nice way to interrupt and resume lists in this way (without explicitly setting some counter), but I can't reproduce it.
I like enumitem for this sort of thing:
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}
\item List item
\item Another list item
\end{enumerate}
Paragraph of comments on list items 1 and 2.
\begin{enumerate}[resume]
\item Further item
\item Final item
\end{enumerate}
\end{document}
The TeX FAQ lists several ways of doing this. Read here for full details.
I've successfully used the mdwlist package (which is part of mdwtools) in my own documents. For example:
\documentclass{article}
\usepackage{mdwlist}
\begin{document}
\begin{enumerate}
\item List item
\item Another list item
\suspend{enumerate}
Paragraph of comments on list items 1 and 2.
\resume{enumerate}
\item Further item
\item Final item
\end{enumerate}
\end{document}
Thanks to Dervin Thunk for providing the FAQ link.
\documentclass{article}
\begin{document}
\begin{enumerate}
\item first;
\item second;
\end{enumerate}
This is a paragraph.
\begin{enumerate}
\setcounter{enumi}{2}
\item third;
\item and so on...
\end{enumerate}
\end{document}
edit: as pointed out by Dervin Thunk, I hardcoded 2 here.
so, here's a solution that seems to work:
\documentclass{article}
\newcounter{tempcounter}
\begin{document}
\begin{enumerate}
\item first;
\item second;
\setcounter{tempcounter}{\value{enumi}}
\end{enumerate}
This is a paragraph.
\begin{enumerate}
\setcounter{enumi}{\value{tempcounter}}
\item third;
\item and so on...
\end{enumerate}
\end{document}
You can use newcounter and usecounter to get around this -- here's an example.
I have a list/sublist structure in my LaTeX document. By default, the sublist is delimited with letters, so you end up with this:
1. Item
(a) sub item
(b) sub item
In my document, I've got more than 26 sub items, so I was running into a Counter overflow error, which I fixed by rewriting the sub item label, so that they now look like this
1. Item
1.1 sub item
1.2 sub item
I've put a label on one of the items so that I can reference the specific step later on. The problem is that when the reference is rendered, it's rendered using a letter, not the number of the sub item.
Here's a sample doc that shows the problem.
\documentclass[11pt]{report}
\begin{document}
\renewcommand{\labelenumii}{\arabic{enumi}.\arabic{enumii}}
\begin{enumerate}
\item Item
\begin{enumerate}
\item \label{lbl} Label here
\end{enumerate}
\end{enumerate}
Ref: \ref{lbl}
\end{document}
This gets rendered like this:
1. Item
1.1 Label here
Ref: 1a
So instead of saying "Ref: 1.1", it's using "Ref: 1.a". Is there a way to make the \ref use the numbering of the source enumeration? If not, is there anyway to generate correct references to items in a sublist with more than 26 items?
I'm looking at my copy of The LaTeX Companion, p.129, and from what I'm seeing I would suggest something like the following:
\renewcommand{\theenumii}{\arabic{enumii}}
\renewcommand{\labelenumii}{\theenumi.\theenumii.}
\makeatletter
\renewcommand{\p#enumii}{\theenumi.}
\makeatother
I don't have access to a working LaTeX environment to test this at the moment, though.
So for 2 nested lists it should be done in the following way:
\begin{enumerate}
\renewcommand{\theenumi}{\arabic{enumi}}
\renewcommand{\theenumii}{\arabic{enumii}}
\renewcommand{\theenumiii}{\arabic{enumiii}}
\renewcommand{\labelenumi}{\theenumi.}
\renewcommand{\labelenumii}{\theenumi.\theenumii.}
\renewcommand{\labelenumiii}{\theenumi.\theenumii.\theenumiii.}
\makeatletter
\renewcommand{\p#enumii}{\theenumi.}
\renewcommand{\p#enumiii}{\theenumi.\theenumii.}
\makeatother
...
\end{enumerate}
It has taken to me too much time to understand it.
I hope this helps as this thread helped me.
Thanks.