0

I have a character string that I would like to output in a better format. Currently, my program is something like this:

\documentclass[12pt,english,nohyper]{tufte-handout}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackaage{hyperref}
\usepackage{graphicx}
\usepackage[space]{grffile}
\usepackage{geometry}

\makeatletter
\makeatother

\begin{document}
\SweaveOpts{concordance=TRUE}

<<include=FALSE>>=
library(ggplot2)
library(reshape2)
library(xtable)
@

\centerline{\Large\bf This is a test}
\vspace{1cm}

\noindent
My List:
\vspace{2mm}

<<echo=FALSE,results='asis'>>=
myList = c("A. This is the first item in my list.", "B. This is the second item in my list, and it will span across two lines because it is so long. This is the second item in my list, and it will span across two lines because it is so long.", "C. This is the third item in my list")
cat("\n\n\n")
cat(myList,sep="\n\n")
@

\end{document}

This leads to an output that looks like this:

(The first line of each element of the character array is auto-indented, which I do not want. Also, if the element spans multiple lines, then its non-first lines begin text output even further-left aligned than the preceding first line)

What I would like my output to look like is more like this:

(Now, the first line of each element of the character array is no longer auto-indented (each element's first line begins at the same indentation as the title "My List". Also, for any element that spans more than one line, the non-first lines have an indent so that the wording begins at the same location as the first line. For example in the second element (B), the word "This" from the first line has the same indentation as the word "second" on the second line)) I am unsure how to accomplish these two format issues. Any advice is greatly appreciated!

EDIT: I took the advice of @NickK, and used the list structure. It mostly solved my problem. However, it did introduce another problem for me, which I opened up on a new thread. Thank you. (Iterating through a character/string array in LaTeX)

Community
  • 1
  • 1
  • 1
    First of all, this looks more like Sweave than knitr or Markdown to me. Secondly, I am unsure of your intent : do you want your list to have no indent, do you want the text to be justified or something else ? And thirdly, I think your formatting issues stem from the fact that you output direcly with `cat ` instead of using `xtable` or a similar package. – Tutuchan Jun 22 '15 at 14:42
  • @Tutuchan, Thanks for your comments. 1) I am sorry. I do often mix these up. 2) Wow! I did not realize that my captions to the two images did not show up when I posted! I added them parenthetically now under each of the images. I tried to explain what I have been attempting to do more clearly. 3) I will play around with xtable. I have not tried that yet. Thanks again. –  Jun 22 '15 at 18:13
  • 1
    I've retagged your question. Since Sweave outputs LaTeX, I suggest you look at how to produce ordered lists in LaTeX e.g. https://en.m.wikibooks.org/wiki/LaTeX/List_Structures . You might find it easier to use Markdown which has simpler syntax for ordered lists. – Nick Kennedy Jun 23 '15 at 05:01
  • @NickK Thank you! That link was very helpful. For the most part, it solved my problem! Except for being able to iterate it in a loop (so I do not have to hard-code each index). I opened up a secondary problem (Hopefully, I should not have kept editing it here, because it introduced a different problem. Thanks again.) (http://stackoverflow.com/questions/31008848/iterating-through-a-character-string-array-in-latex) –  Jun 23 '15 at 18:36

0 Answers0