0

I want to create text like this using latex.

Bold Text1: Normal Text1
Bold Text2: Normal Text2
Bold Text3: Normal Text3
Bold Text4: Normal Text4

So I tried creating my new commands something like this:

\newcommand{\resumeSubHeadingListStartForProgramming}{\begin{document} \textbf{#1} & #2}
\newcommand{\resumeSubHeadingListEndForProgramming}{\end{document}}

And this is the way I was using but it doesn't work and it is giving me error as "can be used only in preamble"

\section{Testing}
\resumeSubHeadingListStartForProgramming
 {Bold Text1: Normal Text1}
 {Bold Text2: Normal Text2}
 {Bold Text3: Normal Text3}
 {Bold Text4: Normal Text4}
\resumeSubHeadingListEndForProgramming

Update:

This is how I want to create text:

enter image description here

Partha D.
  • 2,250
john
  • 103
  • Welcome to TeX.Stackexchange. How can there be several \begin{documents} and \end{documents} after a \section{...} command ? I think you want some environment like quote rather than document ! ...Additionally to use #1 and #2 as arguments inside your command, you should use \newcommand{\resumeSubHeadingListStartForProgramming}[2]{...} – Partha D. Feb 13 '19 at 07:32
  • @ParthaD. what should I have inside {...}? Basically I just need to make texts like I have shown above by using my new command. – john Feb 13 '19 at 07:37
  • @john Can you show an example of what you want to achieve (maybe a picture) ? – Partha D. Feb 13 '19 at 07:38
  • @ParthaD. updated the question with the image that I am planning to replicate using latex. – john Feb 13 '19 at 07:41

3 Answers3

3

description was born for this purpose

\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}
\begin{document}
\lipsum[1]

\begin{description}[align=right,labelwidth=2.5cm] \item [First bold] Some normal text \item [Second bold] some detail \item [Third bold] some detail \end{description}

\lipsum[2] \end{document}

enter image description here


Edit 1

Is this ok, or it needs some improvement?

%-------------------------
% Resume in Latex
% Author : Sourabh Bajaj
% License : MIT
%------------------------

\documentclass[letterpaper,11pt]{article}

\usepackage{latexsym} \usepackage[empty]{fullpage} \usepackage{titlesec} \usepackage{marvosym} \usepackage[usenames,dvipsnames]{color} \usepackage{verbatim} \usepackage{enumitem} \usepackage[hidelinks]{hyperref} \usepackage{fancyhdr} \usepackage[english]{babel}

\pagestyle{fancy} \fancyhf{} % clear all header and footer fields \fancyfoot{} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt}

% Adjust margins \addtolength{\oddsidemargin}{-0.5in} \addtolength{\evensidemargin}{-0.5in} \addtolength{\textwidth}{1in} \addtolength{\topmargin}{-.5in} \addtolength{\textheight}{1.0in}

\urlstyle{same}

\raggedbottom \raggedright \setlength{\tabcolsep}{0in}

% Sections formatting \titleformat{\section}{ \vspace{-4pt}\scshape\raggedright\large }{}{0em}{}[\color{black}\titlerule \vspace{-5pt}]

%------------------------- % Custom commands \newcommand{\resumeItem}[2]{ \item\small{ {#2 \vspace{-2pt}} } }

\newcommand{\resumeSubheading}[4]{ \vspace{-1pt}\item \begin{tabular}{0.97\textwidth}[t]{l@{\extracolsep{\fill}}r} \textbf{#1} & #2 \ \textit{\small#3} & \textit{\small #4} \ \end{tabular}\vspace{-5pt} }

\newcommand{\resumeSubItem}[2]{\resumeItem{#1}{#2}\vspace{-4pt}}

\renewcommand{\labelitemii}{$\circ$}

\newcommand{\resumeSubHeadingListStart}{\begin{itemize}[leftmargin=*]} \newcommand{\resumeSubHeadingListEnd}{\end{itemize}} \newcommand{\resumeItemListStart}{\begin{itemize}} \newcommand{\resumeItemListEnd}{\end{itemize}\vspace{-5pt}}

\newcommand{\resumeSubHeadingListStartForProgramming}{\begin{description}[align=right,noitemsep,labelwidth=5.5cm]} \newcommand{\resumeSubHeadingListEndForProgramming}{\end{description}} \newcommand{\resumeItemListForProgramming}[2]{\item[#1] #2}

%------------------------------------------- %%%%%% CV STARTS HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

%----------HEADING----------------- \begin{tabular}{\textwidth}{l@{\extracolsep{\fill}}r} \textbf{\href{https://www.linkedin.com/in/david/}{\Large David Boz}} & Email : \href{mailto:davidboz@gmail.com}{davidboz@gmail.com}\ \href{https://www.linkedin.com/in/david/}{https://www.linkedin.com/in/david/} & Mobile : +1-111-111-111 \ \end{tabular}

%-----------SUMMARY----------------- \section{SUMMARY} {Strong interest in building systems that operates on the largest of internet scale. I enjoy working on practical problems at the intersection of distributed systems, massive scale databases and storage infrastructure. Passionate for engineering, distributed scalable systems, search, machine learning, big data and cloud technologies.}

%--------PROGRAMMING SKILLS------------ \section{Programming Skills} \resumeSubHeadingListStartForProgramming \resumeItemListForProgramming{Operating Systems}{Unix (Linux, HP-UX, Solaris, AIX), Windows} \resumeItemListForProgramming{Programming Languages}{Java, C, C++, Objective C, Hibernate, JUnit, JSTL, ASP.NET, C#, VB.NET} \resumeItemListForProgramming{Datastores}{Bigtable, Hadoop, Cassandra, MongoDB, RocksDB, Oracle, MySQL} \resumeItemListForProgramming{Distributed Systems}{Zookeeper, Spark, Storm, Kafka, ZeroMQ} \resumeItemListForProgramming{Web Technologies}{HTML, XML, CSS} \resumeItemListForProgramming{Scripting}{Python, JavaScript, Perl, jQuery, Perl} \resumeItemListForProgramming{IDEs}{Eclipse, IntelliJ, Net Beans, Visual Studio .NET} \resumeItemListForProgramming{Application Servers}{Apache HTTP Server, Apache Tomcat} \resumeItemListForProgramming{Enterprise Search Platform}{Apache Solr} \resumeItemListForProgramming{Frameworks}{Spring MVC, Apache Struts, Java Server Faces} \resumeItemListForProgramming{Source Control Systems}{Git, Subversion, ClearCase} \resumeItemListForProgramming{Automation}{Ansible/Ansible Tower, Puppet} \resumeItemListForProgramming{Virtualisation}{Docker, Vagrant} \resumeSubHeadingListEndForProgramming

%-----------PROJECTS----------------- \section{Projects} \resumeSubHeadingListStart \resumeSubItem{} {Designed and implemented a spatial micro blogging system using Android mobile phones. With this system, users utilize their mobile phones to post micro blog entries, geo-tag them, and insert them into a database. Users can use this database of geo-tagged micro blogs for querying. Users can see the results of each query either textually on a list or spatially on Android phone’s map.} \resumeSubItem{} {Used ASP.NET, C# to create a multimedia application for Video Streaming, Video Compression, Video Enhancing and Image Search in images & video.} \resumeSubItem{} {Created a data reading application to read xml files.} \resumeSubHeadingListEnd %------------------------------------------- \end{document}

I added \resumeSubHeadingListEnd to the end of the last list to avoid error and define a new command (\resumeItemListForProgramming) for each item in the description environment (represented by \resumeSubHeadingListStartForProgramming and \resumeSubHeadingListEndForProgramming.

enter image description here

  • I see a new line with space between First bold, Second bold and Third bold. Is there any way to have a new line but no extra space between those three lines? – john Feb 13 '19 at 07:43
  • @john Add option noitemsep: Use [align=right,labelwidth=2.5cm,noitemsep] instead of [align=right,labelwidth=2.5cm]. –  Feb 13 '19 at 07:46
  • got it.. also can you tell me how to create newCommand to do exact same thing which you did for First bold, Second bold and Third bold? I tried like this \newcommand{\resumeSubHeadingListStartForProgramming}[2]{\begin{description}[noitemsep] \item \textbf{#1} & #2} \newcommand{\resumeSubHeadingListEndForProgramming}{\end{description}}. Does this look right? – john Feb 13 '19 at 07:49
  • @john In this case, don't define new commands. Define a new environment instead. –  Feb 13 '19 at 07:54
  • As I can see, you are going to make a table. There is already an environment for you: tabular. –  Feb 13 '19 at 07:54
  • Can you tell me why I should not define new commands? In my resume I am using lot of new commands and it works fine for all the cases so I thought I can do something similar here as well. – john Feb 13 '19 at 15:55
  • 1
    @john If you are going to put a small number of text in a formatted place, you should use commands, like what \scriptsize, \footnotesize do, e.g. {\scriptsize Hello}. But if the amount of text is large, or it is complicated, you should never use commands. Use environments instead, like \begin{footnotesize} \end{footnotesize}. –  Feb 13 '19 at 16:00
1

Maybe this is close to what you want:

enter image description here

produced by this code:

\documentclass{scrartcl}
\usepackage{times}
\usepackage{array}% for extended column definitions    
\begin{document}

\begin{tabular}{>{\bfseries}p{0.5\textwidth} p{0.5\textwidth}}
Operating systems     &  Unix (Linux, HP-UX, \ldots) \\
Programming Languages &  Java, C, C++, Objective C, Hibernate, JUnit, JSTL, ASP.NET, C\#, VB.NET \\
Datastores            &  Bigtable, Hadoop, Cassandra, MongoDB, RocksDB, Oracle, MySQL
\end{tabular}

\end{document}
Partha D.
  • 2,250
  • All the previous solutions are perfect and IMO must be prefered, but dont exactly address the OP's question,. The basic difference, and difficulty is that he want a command that would be automatically maped to a list of arguments. In such case I would use the list processing abilities of etoolbox package, or more easily of listofitems package. I could provide an expanded answer if requested. – Jhor Feb 13 '19 at 09:09
  • @Jhor Why not-- me/ we too can learn in that way ! – Partha D. Feb 13 '19 at 10:35
  • @Jhor Can you provide your answer so that I can learn as well? – john Feb 13 '19 at 15:55
1

Here my suggested solution. It's intended for pedagogical purpose, because, as already stated in my comment, the direct implementation of a table or description is much more direct and simple. TBMK, LaTeX lacks a method to map a macro onto a list, hence we have to parse the list an use a loop.

There are dozen of methods to make a loop, as summarized in the post How to iterate over a comma separated list? on this site. Here I show how to implement a solution of the original question by using the listofitems package, that i find very convenient.

The list processing abilities of etoolbox package are much more efficient and robust (i use them systematically when I write a package) but, with listofitems, we can easily parse and iterate on multilevel lists, which is really suited here.

In the following MWE, I show how to parse the list in the OP and use it to create either a tabular as in @Partha D. answer, and a description as in the initial answer from @JouleV.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{listofitems}    % for the list parsing and loop
\usepackage{environ}        % for handling the env BODY         
\usepackage{array}          % for tabular solution 
\usepackage{enumitem}       % for description solution
\usepackage{etoolbox}       % for \xappto


\NewEnviron{testtab}{%
\setsepchar{;/:} \ignoreemptyitems 
\readlist*\mylist\BODY%
\xdef\tmp{}%
\foreachitem\skill\in\mylist{%
    \xappto\tmp{\mylist[\skillcnt,1]&\mylist[\skillcnt,2]\cr}%
}\noindent%
\begin{tabular}{@{}>{\bfseries}p{0.4\textwidth}@{}p{0.6\textwidth}}
\tmp
\end{tabular}
}

\NewEnviron{testdes}{%
\setsepchar{;/:} \ignoreemptyitems 
\readlist*\mylist\BODY
\setlist[description]{font=\bfseries,align=parleft,labelwidth=0.4\textwidth,leftmargin=0.4\textwidth,noitemsep,labelsep=0pt,itemindent=!}
\begin{description}
    \foreachitem\skill\in\mylist{%
        \itemtomacro\mylist[\skillcnt,1]\skillkind%
        \item[\skillkind] \mylist[\skillcnt,2]
    }
\end{description}
}

\begin{document}
\subsection*{\sffamily Description,with \texttt{enumitem} settings}

\begin{testdes}
Operating systems     :  Unix (Linux, HP-UX, \ldots) ;
Programming Languages :  Java, C, C++, Objective C, Hibernate, JUnit, JSTL, ASP.NET, C\#, VB.NET ; 
Datastores            :  Bigtable, Hadoop, Cassandra, MongoDB, RocksDB, Oracle, MySQL ;
\end{testdes}

\subsection*{\sffamily Table, with \texttt{array} settings}

\begin{testtab}
Operating systems     :  Unix (Linux, HP-UX, \ldots) ;
Programming Languages :  Java, C, C++, Objective C, Hibernate, JUnit, JSTL, ASP.NET, C\#, VB.NET ;
Datastores            :  Bigtable, Hadoop, Cassandra, MongoDB, RocksDB, Oracle, MySQL ;
\end{testtab}

\end{document}

giving the expected result: enter image description here

In this code, we use the environ package which is necessary to retrieve the environment content (as the macro \BODY), enabling to process it as a whole. In both defined environment, \BODY is read and parsed by \readlist*\mylist\BODY, where the star ask for trimming extra white-spaces. The setting preceding this line define the separators ";" for first level and ":" for second level, and ask to ignore empty items.

Notice that I was lead to delete the surrounding braces on each line, and to add the ";" separators. Of course the list items delimited by curly braces could ne parsed by using " " as first level separator but the ":" is then not accessible to \readlist. A workarround would then to read only one level, and first strip the braces (e.g. with \StrRemoveBraces provided by xstring), before reading the second level.

The loop on elements is then done by using the \foreachitem\skill\in\mylist, but here the two methods differ significantly :

  • The description content can be defined iteratively inside the environment itself, hence the code is straightforward (except that \mylist[\skillcnt,1] must be stored in a macro to be accepted as the description item's labels). The formatting is provided by the enumitem package.

  • Oppositely, tabular expect that its content to be not provided line by line, but as a block. It is then necessary to build this content block (in \tmp macro) by looping outside the tabular environment, adding the successive lines with etoolbox's \xappto. The format is provided by the array package.

Jhor
  • 4,179