├── latex-surveys.pdf ├── .gitignore ├── README.md └── latex-surveys.tex /latex-surveys.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/annerosenisser/latex-surveys/HEAD/latex-surveys.pdf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore all LaTex auxiliary files 2 | .aux 3 | .bbl 4 | .blg 5 | .log 6 | .out 7 | .toc 8 | .synctex.gz -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Latex Surveys 2 | Template for nicely formatted surveys in LaTeX. 3 | 4 | This code was authored by [Sven Hartenstein](www.svenhartenstein.de). I found it [here](http://www.svenhartenstein.de/creating-questionnaires-with-latex/) and thought it would be good to share on GitHub. 5 | 6 | Ideally, one should build a LaTeX package from this code (shouldn't be too difficult). 7 | -------------------------------------------------------------------------------- /latex-surveys.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper,10pt,BCOR10mm,oneside,headsepline]{scrartcl} 2 | \usepackage[ngerman]{babel} 3 | \usepackage[utf8]{inputenc} 4 | \usepackage{wasysym}% provides \ocircle and \Box 5 | \usepackage{enumitem}% easy control of topsep and leftmargin for lists 6 | \usepackage{color}% used for background color 7 | \usepackage{forloop}% used for \Qrating and \Qlines 8 | \usepackage{ifthen}% used for \Qitem and \QItem 9 | \usepackage{typearea} 10 | \areaset{17cm}{26cm} 11 | \setlength{\topmargin}{-1cm} 12 | \usepackage{scrpage2} 13 | \pagestyle{scrheadings} 14 | \ihead{Example questionnaire created with \LaTeX} 15 | \ohead{\pagemark} 16 | \chead{} 17 | \cfoot{} 18 | 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | %% Beginning of questionnaire command definitions %% 21 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22 | %% 23 | %% 2010, 2012 by Sven Hartenstein 24 | %% mail@svenhartenstein.de 25 | %% http://www.svenhartenstein.de 26 | %% 27 | %% Please be warned that this is NOT a full-featured framework for 28 | %% creating (all sorts of) questionnaires. Rather, it is a small 29 | %% collection of LaTeX commands that I found useful when creating a 30 | %% questionnaire. Feel free to copy and adjust any parts you like. 31 | %% Most probably, you will want to change the commands, so that they 32 | %% fit your taste. 33 | %% 34 | %% Also note that I am not a LaTeX expert! Things can very likely be 35 | %% done much more elegant than I was able to. If you have suggestions 36 | %% about what can be improved please send me an email. I intend to 37 | %% add good tipps to my website and to name contributers of course. 38 | %% 39 | %% 10/2012: Thanks to karathan for the suggestion to put \noindent 40 | %% before \rule! 41 | 42 | %% \Qq = Questionaire question. Oh, this is just too simple. It helps 43 | %% making it easy to globally change the appearance of questions. 44 | \newcommand{\Qq}[1]{\textbf{#1}} 45 | 46 | %% \QO = Circle or box to be ticked. Used both by direct call and by 47 | %% \Qrating and \Qlist. 48 | \newcommand{\QO}{$\Box$}% or: $\ocircle$ 49 | 50 | %% \Qrating = Automatically create a rating scale with NUM steps, like 51 | %% this: 0--0--0--0--0. 52 | \newcounter{qr} 53 | \newcommand{\Qrating}[1]{\QO\forloop{qr}{1}{\value{qr} < #1}{---\QO}} 54 | 55 | %% \Qline = Again, this is very simple. It helps setting the line 56 | %% thickness globally. Used both by direct call and by \Qlines. 57 | \newcommand{\Qline}[1]{\noindent\rule{#1}{0.6pt}} 58 | 59 | %% \Qlines = Insert NUM lines with width=\linewith. You can change the 60 | %% \vskip value to adjust the spacing. 61 | \newcounter{ql} 62 | \newcommand{\Qlines}[1]{\forloop{ql}{0}{\value{ql}<#1}{\vskip0em\Qline{\linewidth}}} 63 | 64 | %% \Qlist = This is an environment very similar to itemize but with 65 | %% \QO in front of each list item. Useful for classical multiple 66 | %% choice. Change leftmargin and topsep accourding to your taste. 67 | \newenvironment{Qlist}{% 68 | \renewcommand{\labelitemi}{\QO} 69 | \begin{itemize}[leftmargin=1.5em,topsep=-.5em] 70 | }{% 71 | \end{itemize} 72 | } 73 | 74 | %% \Qtab = A "tabulator simulation". The first argument is the 75 | %% distance from the left margin. The second argument is content which 76 | %% is indented within the current row. 77 | \newlength{\qt} 78 | \newcommand{\Qtab}[2]{ 79 | \setlength{\qt}{\linewidth} 80 | \addtolength{\qt}{-#1} 81 | \hfill\parbox[t]{\qt}{\raggedright #2} 82 | } 83 | 84 | %% \Qitem = Item with automatic numbering. The first optional argument 85 | %% can be used to create sub-items like 2a, 2b, 2c, ... The item 86 | %% number is increased if the first argument is omitted or equals 'a'. 87 | %% You will have to adjust this if you prefer a different numbering 88 | %% scheme. Adjust topsep and leftmargin as needed. 89 | \newcounter{itemnummer} 90 | \newcommand{\Qitem}[2][]{% #1 optional, #2 notwendig 91 | \ifthenelse{\equal{#1}{}}{\stepcounter{itemnummer}}{} 92 | \ifthenelse{\equal{#1}{a}}{\stepcounter{itemnummer}}{} 93 | \begin{enumerate}[topsep=2pt,leftmargin=2.8em] 94 | \item[\textbf{\arabic{itemnummer}#1.}] #2 95 | \end{enumerate} 96 | } 97 | 98 | %% \QItem = Like \Qitem but with alternating background color. This 99 | %% might be error prone as I hard-coded some lengths (-5.25pt and 100 | %% -3pt)! I do not yet understand why I need them. 101 | \definecolor{bgodd}{rgb}{0.8,0.8,0.8} 102 | \definecolor{bgeven}{rgb}{0.9,0.9,0.9} 103 | \newcounter{itemoddeven} 104 | \newlength{\gb} 105 | \newcommand{\QItem}[2][]{% #1 optional, #2 notwendig 106 | \setlength{\gb}{\linewidth} 107 | \addtolength{\gb}{-5.25pt} 108 | \ifthenelse{\equal{\value{itemoddeven}}{0}}{% 109 | \noindent\colorbox{bgeven}{\hskip-3pt\begin{minipage}{\gb}\Qitem[#1]{#2}\end{minipage}}% 110 | \stepcounter{itemoddeven}% 111 | }{% 112 | \noindent\colorbox{bgodd}{\hskip-3pt\begin{minipage}{\gb}\Qitem[#1]{#2}\end{minipage}}% 113 | \setcounter{itemoddeven}{0}% 114 | } 115 | } 116 | 117 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 118 | %% End of questionnaire command definitions %% 119 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 120 | 121 | \begin{document} 122 | 123 | \begin{center} 124 | \textbf{\huge Example questionnaire created with \LaTeX} 125 | \end{center}\vskip1em 126 | 127 | \noindent Welcome to this very important survey with which we 128 | researchers want to look deep inside of you (be afraid!). Anyway, 129 | thank you for filling it all out. 130 | 131 | \noindent \textit{Please note that no tabular environment is used in 132 | this example questionnaire. Of course, you could use tabular to 133 | create more complex layout.} 134 | 135 | \section*{About you} 136 | 137 | \Qitem{ \Qq{Your name}: \Qline{8cm} } 138 | 139 | \Qitem{ \Qq{How old are you?} I am \Qline{1.5cm} years old.} 140 | 141 | \Qitem{ \Qq{Are you in a good mood right now?} \hskip0.4cm \QO{} 142 | absolutely \hskip0.5cm \QO{} not really because: \Qline{3cm} } 143 | 144 | \Qitem{ \Qq{Do you like having an option?} 145 | \begin{Qlist} 146 | \item Yes, this meets my need for autonomy. 147 | \item No, I'd rather have someone else decide for me. 148 | \item Not sure. 149 | \end{Qlist} 150 | } 151 | 152 | \Qitem{ \Qq{What kind of music do you like best?} 153 | \begin{Qlist} 154 | \item Johann Sebastian Bach 155 | \item Jazz 156 | \item The Beatles 157 | \item Other: \Qline{4cm} 158 | \end{Qlist} 159 | } 160 | 161 | \minisec{Please evaluate the following composers} 162 | \vskip.5em 163 | 164 | \Qitem[a]{ \Qq{Mozart} \Qtab{3cm}{horrible \Qrating{5} fantastic}} 165 | 166 | \Qitem[b]{ \Qq{Beethoven} \Qtab{3cm}{horrible \Qrating{5} fantastic}} 167 | 168 | \Qitem[c]{ \Qq{Johann S. Bach} \Qtab{3cm}{horrible \Qrating{5} 169 | fantastic}} 170 | 171 | \Qitem[d]{ \Qq{John Lennon}\Qtab{2.5cm}{\parbox[t]{3.3cm}{\raggedleft 172 | Uh, well, I do not like his music very much} 173 | \Qrating{7} \parbox[t]{3cm}{Oh, yes, you know, really great 174 | stuff}}} 175 | 176 | \Qitem[e]{ \Qq{Elvis}\Qtab{2.5cm}{\parbox[t]{3.3cm}{\raggedleft Uh, 177 | well, I do not like his music very much} 178 | \Qrating{7} \parbox[t]{3cm}{Oh, yes, you know, really great 179 | stuff}}} 180 | 181 | \section*{About this questionnaire} 182 | 183 | \Qitem{\Qq{Do you like the style so far?} \Qtab{5.5cm}{\QO{} Yes 184 | \hskip0.5cm \QO{} No}} 185 | 186 | \Qitem{\Qq{Is it really worth the ink?} \Qtab{5.5cm}{\QO{} Guess so. 187 | \hskip0.5cm \QO{} Probably not. \hskip0.5cm \QO{} Don't know.}} 188 | 189 | \Qitem{\Qq{How does this item look different from the previous one?} 190 | \Qtab{10.5cm}{\QO{}\Qtab{0.6cm}{Oh. Does it?}}\par 191 | \Qtab{10.5cm}{\QO{}\Qtab{0.6cm}{No clue. I just can't figure it out. 192 | So sorry.}}\par 193 | \Qtab{10.5cm}{\QO{}\Qtab{0.6cm}{I guess what you mean is that here 194 | the different answer options are below each other.}}\par 195 | } 196 | 197 | \Qitem[a]{ \Qq{Please describe your first impression.} \Qlines{2} } 198 | 199 | \Qitem[b]{ \Qq{In case you would like some more lines to write, here 200 | they are:} \Qlines{4} } 201 | 202 | \section*{Another feature} 203 | 204 | \noindent Now, here is another nice feature: you can automatically 205 | alter the background color of the items. Here is how it can look like. 206 | Because we are too lazy to think of new questions we will just ask you 207 | the same questions again. There is one difference to the above though, 208 | can you find it? 209 | 210 | \renewcommand{\QO}{$\ocircle$}% Use circles now instead of boxes. 211 | 212 | \section*{About you} 213 | 214 | \QItem{ \Qq{Your name}: \Qline{8cm} } 215 | 216 | \QItem{ \Qq{How old are you?} I am \Qline{1.5cm} years old.} 217 | 218 | \QItem{ \Qq{Are you in a good mood right now?} \hskip0.4cm \QO{} 219 | absolutely \hskip0.5cm \QO{} not really because: \Qline{3cm} } 220 | 221 | \QItem{ \Qq{Do you like having an option?} 222 | \begin{Qlist} 223 | \item Yes, this meets my need for autonomy. 224 | \item No, I'd rather have someone else decide for me. 225 | \item Not sure. 226 | \end{Qlist} 227 | } 228 | 229 | \QItem{ \Qq{What kind of music do you like best?} 230 | \begin{Qlist} 231 | \item Johann Sebastian Bach 232 | \item Jazz 233 | \item The Beatles 234 | \item Other: \Qline{4cm} 235 | \end{Qlist} 236 | } 237 | 238 | \minisec{Please evaluate the following composers} 239 | \vskip.5em 240 | 241 | \QItem[a]{ \Qq{Mozart} \Qtab{3cm}{horrible \Qrating{5} fantastic}} 242 | 243 | \QItem[b]{ \Qq{Beethoven} \Qtab{3cm}{horrible \Qrating{5} fantastic}} 244 | 245 | \QItem[c]{ \Qq{Johann S. Bach} \Qtab{3cm}{horrible \Qrating{5} fantastic}} 246 | 247 | \QItem[d]{ \Qq{John Lennon}\Qtab{2.5cm}{\parbox[t]{3.3cm}{\raggedleft 248 | Uh, well, I do not like his music very much} 249 | \Qrating{7} \parbox[t]{3cm}{Oh, yes, you know, really great 250 | stuff}}} 251 | 252 | \QItem[e]{ \Qq{Elvis}\Qtab{2.5cm}{\parbox[t]{3.3cm}{\raggedleft 253 | Uh, well, I do not like his music very much} 254 | \Qrating{7} \parbox[t]{3cm}{Oh, yes, you know, really great 255 | stuff}}} 256 | 257 | \section*{About this questionnaire} 258 | 259 | \QItem{\Qq{Do you like the style so far?} \Qtab{5.5cm}{\QO{} Yes 260 | \hskip0.5cm \QO{} No}} 261 | 262 | \QItem{\Qq{Is it really worth the ink?} \Qtab{5.5cm}{\QO{} Guess so. 263 | \hskip0.5cm \QO{} Probably not. \hskip0.5cm \QO{} Don't know.}} 264 | 265 | \QItem{\Qq{How does this item look different from the previous one?} 266 | \Qtab{10.5cm}{\QO{}\Qtab{0.6cm}{Oh. Does it?}}\par 267 | \Qtab{10.5cm}{\QO{}\Qtab{0.6cm}{No clue. I just can't figure it out. 268 | So sorry.}}\par 269 | \Qtab{10.5cm}{\QO{}\Qtab{0.6cm}{I guess what you mean is that here 270 | the different answer options are below each other.}}\par 271 | } 272 | 273 | \QItem[a]{ \Qq{Please describe your first impression.} \Qlines{2} } 274 | 275 | \QItem[b]{ \Qq{In case you would like some more lines to write, here 276 | they are:} \Qlines{4} } 277 | 278 | \end{document} --------------------------------------------------------------------------------